0

Depend on this tutorials grpc basic

I clone https://github.com/grpc/grpc to local,

cd example/python/helloworld start server python greeter_server.py

then start client python greeter_client.py, but get error

Traceback (most recent call last):
  File "greeter_client.py", line 35, in <module>
  run()
  File "greeter_client.py", line 30, in run
    response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'))
  File "/usr/local/lib/python3.7/site-packages/grpc/_channel.py", line 533, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/usr/local/lib/python3.7/site-packages/grpc/_channel.py", line 467, in _end_unary_response_blocking
    raise _Rendezvous(state, None, None, deadline) grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
      status = StatusCode.UNAVAILABLE
      details = "Socket closed"
      debug_error_string = "{"created":"@1541228979.471085000","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1017,"grpc_message":"Socket closed","grpc_status":14}"

then I execuse sudo python greeter_client.py, get the correct result.

Why I should add sudo to get the correct result?

5
  • I use python2 and python3 get the same error Commented Nov 3, 2018 at 7:17
  • Can you provide more information about your environment? This seems like most likely a machine configuration issue, so it would also be helpful if you could rule out a local configuration problem by checking if a non-gRPC server/client on the same port will work. Commented Nov 7, 2018 at 18:43
  • I have same issue. unfortunately "sudo" doesn't help; i am running it on ubuntu16.04. I can run this example inside centos 7 docker containers Commented Nov 7, 2018 at 22:43
  • I found I set a global http proxy, so I change 'localhost' to '127.0.0.1', it's fine. Commented Nov 9, 2018 at 3:00
  • I had a similar error, when i was trying to connect to a secure port with an insecured channel, so keep that in mind too. Commented Feb 23, 2021 at 13:51

2 Answers 2

1
  1. I found I set a global http proxy export http_proxy=http://127.0.0.1:1087, I closed this proxy, then It was find.

  2. update greeter_client.py, change localhost to 127.0.0.1. It's find to me.

Sign up to request clarification or add additional context in comments.

Comments

0

Could you try few options and share your feedback:

Option - 1

another port(except 50051) in client and server?

Option-2

Try with 0.0.0.0 in client

Thanks, Dheeraj

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.