4
votes

We are running "helloworld" example from https://grpc.io/docs/quickstart/cpp.html#update-a-grpc-service and we received the following ERROR:

14: Connect Failed

Greeter received: RPC failed.

The server and the client are listening on: 0.0.0.0:50051. The Server is running. First we receive just a packet on the server and the client crashes, I checked it with tcpdump. We checked on different hosts as well as on the same host but it didn't work for either cases. Should we change a different IP or different Port number?

1
Solved it! you need to unset your proxy at both sides with the following command: $unset http_proxy $http_proxy="" - alevsof

1 Answers

3
votes

I got the same issue on my PC(OS: ubuntu 16.04 LTS, protobuf 3.4.0)

so I search for the reason and I found this:

Reason

If on a linux machine, the environment has the usual "http_proxy" environment variable configured, gRPC will take that into account when trying to connect, however, will then proceed to ignore the companion no_proxy setting:

For example:

$ env
http_proxy=http://106.1.216.121:8080
no_proxy=localhost,127.0.0.1

$ ./greeter_client
D0306 16:00:11.419586349 1897 combiner.c:351] C:0x25a9290 finish old_state=3
D0306 16:00:11.420527744 1896 tcp_client_posix.c:179] CLIENT_CONNECT: ipv4:106.1.216.121:8080: on_writable: error="No Error"
D0306 16:00:11.420567382 1896 combiner.c:145] C:0x25a69a0 create
D0306 16:00:11.420581887 1896 tcp_client_posix.c:119] CLIENT_CONNECT: ipv4:106.1.216.121:8080: on_alarm: error="Cancelled"
I0306 16:00:11.420617663 1896 http_connect_handshaker.c:319] Connecting to server 127.0.0.1:50051 via HTTP proxy ipv4:106.1.216.121:8080

Basically, it's using the http_proxy url to connect even though localhost is in the no_proxy list. Since the default for no_proxy includes localhost on most linux machines; the end result is that any user with an http_proxy configured will never be able to connect to localhost. --- [1]


Other solution

You can enable grpc tracing with export GRPC_TRACE=all && ./greeter_server and same thing for the client.

Verification

Terminal 1 enter image description here Terminal 2 enter image description here

That should do the trick

ps. for more information about GRPC_TRACE - gRPC environment variables

Reference

  1. gRPC doesn't respect the no_proxy environment variable