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

运行grpc python示例必须使用sudo命令,python,grpc,grpc-python,Python,Grpc,Grpc Python,依赖本教程 我克隆https://github.com/grpc/grpc到本地 cd示例/python/helloworld 启动服务器python-greeter\u-server.py 然后启动clientpython greeter\u client.py, 但是得到错误 Traceback (most recent call last): File "greeter_client.py", line 35, in <module> run() File "gre

依赖本教程

我克隆
https://github.com/grpc/grpc
到本地

cd示例/python/helloworld
启动服务器
python-greeter\u-server.py

然后启动client
python greeter\u 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}"
回溯(最近一次呼叫最后一次):
文件“greeter_client.py”,第35行,在
运行()
文件“greeter_client.py”,第30行,正在运行
response=stub.SayHello(helloworld\u pb2.HelloRequest(name='you'))
文件“/usr/local/lib/python3.7/site packages/grpc/_channel.py”,第533行,在调用中__
返回\u结束\u一元\u响应\u阻塞(状态、调用、错误、无)
文件“/usr/local/lib/python3.7/site packages/grpc/_channel.py”,第467行,输入一元响应
提升集合点(状态,无,无,截止日期)grpc.\u通道。\u集合点:

  • 我发现我设置了一个全局http代理
    导出http\u代理=http://127.0.0.1:1087
    ,我关闭了此代理,然后找到了它

  • 更新
    greeter\u client.py
    ,将
    localhost
    更改为
    127.0.0.1
    。这对我来说很难找到


  • 您能否尝试一些选项并分享您的反馈:

    选项-1

    和中的另一个端口(50051除外)

    选项2

    在中尝试使用0.0.0.0

    谢谢,
    Dheeraj

    我使用python2和python3得到相同的错误你能提供更多关于你的环境的信息吗?这看起来很可能是一个机器配置问题,因此如果您可以通过检查同一端口上的非gRPC服务器/客户端是否工作来排除本地配置问题,这也会很有帮助。我也有同样的问题。不幸的是,“sudo”没有帮助;我正在ubuntu16.04上运行它。我可以在centos 7 docker Containers中运行此示例。我发现我设置了一个全局http代理,所以我将“localhost”更改为“127.0.0.1”,这很好。我在尝试使用不安全的通道连接到安全端口时也遇到了类似的错误,所以请记住这一点。