简体   繁体   English

运行grpc python示例必须使用sudo命令

[英]run grpc python example must use sudo command

Depend on this tutorials grpc basic 依赖于本教程grpc basic

I clone https://github.com/grpc/grpc to local, 我将https://github.com/grpc/grpc克隆到本地,

cd example/python/helloworld start server python greeter_server.py cd example/python/helloworld启动服务器python greeter_server.py

then start client python greeter_client.py , but get error 然后启动客户端python greeter_client.py ,但出现错误

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. 然后我执行sudo python greeter_client.py ,得到正确的结果。

Why I should add sudo to get the correct result? 为什么我应该添加sudo以获得正确的结果?

  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. 我发现我设置了一个全局http代理export http_proxy=http://127.0.0.1:1087 ,我关闭了该代理,然后找到了。

  2. update greeter_client.py , change localhost to 127.0.0.1 . 更新greeter_client.py ,将localhost更改为127.0.0.1 It's find to me. 找到我了。

Could you try few options and share your feedback: 您能否尝试几种选择并分享您的反馈意见:

Option - 1 选项1

another port(except 50051) in client and server ? 客户端服务器中的另一个端口(50051除外)?

Option-2 选项2

Try with 0.0.0.0 in client 客户端尝试使用0.0.0.0

Thanks, Dheeraj 谢谢,Dheeraj

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM