kataras / kataras/iris

Grpc not working as expected

Open
#1,985 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
25.6k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Describe the issue you are facing or ask for help

@kataras, it is not a issue, rather a question.
It is been three days, I am trying the mvc.Grpc. I didn't try the example provided in the repo.

But, I keep getting this error.
```
"err rpc error: code = Unimplemented desc = unexpected HTTP status code received from server: 404 (Not Found); transport: received unexpected content-type "text/plain; charset=utf-8"
```

If I serve my grpc service using standard grpc provided documentation, it is working.

```
lis, _ := net.Listen("tcp", fmt.Sprintf("localhost:%d", 50051))
serv.Serve(lis)
```

And if I serve the server using Iris like below, it works only on postman or over http.Post
```
app.Run(
iris.TLS("localhost:50051", "config/server.crt", "config/server.key")
)
```
I tried different hostname, such as "127.0.0.1" or "0.0.0.0" also tried without hostname, only the port. Nothing works.

On my client side, I also tried different credentials. No luck at all.
```
// cred, err := credentials.NewClientTLSFromFile("./server.crt", "")
// or
// cred := insecure.NewCredentials()
// or
cred := credentials.NewTLS(&tls.Config{
InsecureSkipVerify: true,
Renegotiation: tls.RenegotiateNever,
})

conn, err := grpc.Dial(
address,
grpc.WithTransportCredentials(cred),
)
```

Server example, I did also tried with different strict mode.
```
app := iris.New()
app.Logger().SetLevel("debug")
handler := internal.CreateGrpcHandler()

serv := grpc.NewServer()
pb.RegisterApiServer(serv, handler)

mvc.New(app).
Handle(handler, mvc.GRPC{
Server: serv, // Required.
ServiceName: "product.Api", // Required.
Strict: false,
})
app.Run(
addr = iris.TLS(config.GRPC_ADDR, "config/server.crt", "config/server.key"),
)
```
The logs shows it is running, and as I said, the https over postman working.
```
[DBUG] internal.grpcHandler
╺ Create
POST /product.Api/Create
• context.Context
• *product.CreateProductReq → ...:32
╺ Delete
POST /product.Api/Delete
• context.Context
• *product.DeleteProductReq → ...:32
╺ Read
POST /product.Api/Read
• context.Context
• *product.ReadProductReq → ...o:32
╺ Update
POST /product.Api/Update
• context.Context
• *product.UpdateProductReq → ...:32
[DBUG] 2022/10/14 23:24 API: 5 registered routes (1 GET and 4 POST)
GET: / (./cmd/grpc.go:24)

POST: /product.Api/Create gRPC internal.grpcHandler (./cmd/grpc.go:32)
• internal.grpcHandler.Create (./internal/grpc.go:16)
POST: /product.Api/Delete gRPC internal.grpcHandler (./cmd/grpc.go:32)
• internal.grpcHandler.Delete (./internal/grpc.go:47)
POST: /product.Api/Read gRPC internal.grpcHandler (./cmd/grpc.go:32)
• internal.grpcHandler.Read (./internal/grpc.go:33)
POST: /product.Api/Update gRPC internal.grpcHandler (./cmd/grpc.go:32)
• internal.grpcHandler.Update (./internal/grpc.go:40)

Iris Version: 12.2.0-beta5

Now listening on: https://localhost:50051
Application started. Press CTRL+C to shut down.
```
I am quite confused now, either the beta version is broken or I missed something in my code.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.