簡體   English   中英

運行grpc python示例必須使用sudo命令

[英]run grpc python example must use sudo command

依賴於本教程grpc basic

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

cd example/python/helloworld啟動服務器python greeter_server.py

然后啟動客戶端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}"

然后我執行sudo python greeter_client.py ,得到正確的結果。

為什么我應該添加sudo以獲得正確的結果?

  1. 我發現我設置了一個全局http代理export http_proxy=http://127.0.0.1:1087 ,我關閉了該代理,然后找到了。

  2. 更新greeter_client.py ,將localhost更改為127.0.0.1 找到我了。

您能否嘗試幾種選擇並分享您的反饋意見:

選項1

客戶端服務器中的另一個端口(50051除外)?

選項2

客戶端嘗試使用0.0.0.0

謝謝,Dheeraj

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM