GRPC C ++, client: "14: connection failed"

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

14: Connection error

Greeter received: RPC error.

The server and client are heard: 0.0.0.0:50051

. The server is running. At first we only get the package on the server and the client crashes, I checked it with tcpdump. We tested different hosts and also on the same host, but it didn't work for any of the cases. Should we change another IP or a different port number?

+3


source to share


1 answer


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

so i searched for the reason and i found this:

Cause

If on a linux machine the environment has the usual "http_proxy" environment variable, then gRPC takes this into account when trying to connect, however, it will continue to ignore the no_proxy setting for the companion:

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 uses the http_proxy url to connect, even though localhost is in the no_proxy list. Because the default for no_proxy is localhost on most Linux machines; the end result is that any user with http_proxy configured will never be able to connect to localhost. --- [ 1 ]


Another solution



You can enable grpc tracing using export GRPC_TRACE=all && ./greeter_server

and the same for the client.

Check

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

This should do the trick

ps. for more information on GRPC_TRACE - gRPC environment variables

Link

+1


source







All Articles