0

I have a simple grpc service helloworld. its server is running in ec2 instance behind nginx. I am trying to connect to grpc server from my local machine using curl. I am following the same code that is in official repo so I don't think any problem from code side because I can able to connect to my grpc server from my local grpc client (greeter_client.py).

But when I try in curl I am getting response like this

abci@learnerc MINGW64 ~/Desktop
$ curl -v -H "Content-Type: application/grpc" 3.x6.xx9.xx1:50052/helloworld --http2-prior-knowledge
* Uses proxy env variable no_proxy == 'xxx.xxx.xx.100'
*   Trying x.xx.xxx.xx:50052...
* TCP_NODELAY set
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to 3.xx.xxx.xxx (3.xx.xxx.xxx) port 50052 (#0)
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x6712b0)
> GET /helloworld HTTP/2
> Host: 3.xx.xxx.xxx:50052
> user-agent: curl/7.68.0
> accept: */*
> content-type: application/grpc
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 204
< server: nginx/1.18.0 (Ubuntu)
< date: Fri, 12 Mar 2021 01:57:01 GMT
< grpc-status: 14
< grpc-message: unavailable
<
{ [0 bytes data]
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Connection #0 to host 3.xx.xxx.xxx left intact

My nginx config:

server {
        listen 50052 http2;
        location /helloworld {
         default_type application/grpc;
      grpc_pass grpc://localhost:50051;
        }
    # Error responses
    include conf.d/errors.grpc_conf; # gRPC-compliant error responses
    default_type application/grpc;  
}

The grpc server is running in docker container with exposed port on 50051.

root@ip-xx2-x1-xx-xx:/etc/nginx/sites-enabled# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                      NAMES
xxx        xxx        "/bin/sh -c 'python …"   6 hours ago         Up 6 hours          0.0.0.0:50051->50051/tcp   obje_galois

Thanks. Any help is appreciated.

learner
  • 117
  • 2
  • 10
  • I may misunderstand the issue as I'm unfamiliar with NGINX's support for gRPC but, unless you've got some form of REST-to-gRPC proxy configured, you can't use curl. curl is awesome but it isn't a gRPC client. See [gRPC-web] (https://github.com/grpc/grpc-web) and [gRPCurl](https://github.com/fullstorydev/grpcurl) – DazWilkin Mar 12 '21 at 03:04
  • thanks @DazWilkin. I tried with gRPCurl `grpcurl -plaintext 3.xx.xx.xxx:50052 3.xx.xx.xx:50052.helloworld.Greeter` but getting same error code `204`. – learner Mar 12 '21 at 03:10
  • Can you access the server directly on `:50051`? – DazWilkin Mar 12 '21 at 03:21
  • since nginx is exposing `:50052` i can able to connect to server directly using this port. But not from `:50051`. – learner Mar 12 '21 at 03:27
  • To debug, you want to be able to access the server directly from the client. Then to be able to access the server through the proxy. One without the other, gives you a clue as to which is incorrect. Can the proxy access the gRPC server as `localhost:50051`? I'm out of guidance. – DazWilkin Mar 12 '21 at 04:23
  • 1
    i can able to resolve this. see here: https://github.com/fullstorydev/grpcurl/issues/219 – learner Mar 14 '21 at 22:24

0 Answers0