python - 运行 grpc python 示例必须使用 sudo 命令
问题描述
依赖本教程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 以获得正确的结果?
解决方案
我发现我设置了一个全局 http 代理
export http_proxy=http://127.0.0.1:1087
,我关闭了这个代理,然后就找到了。更新
greeter_client.py
,更改localhost
为127.0.0.1
. 对我来说是找到的。
推荐阅读
- html - 如何使用网格垂直拉伸内容?
- symfony - 如何在将要在生产中呈现的模板中使用“dump()”twig 函数?
- python - CS50 面试问题 - 查找最长的子串递归之谜 - 为什么测试用例 #4 不起作用?
- postgresql - “重复键值违反唯一约束”在预先填充的 postgres 表中添加元素时暴露
- delphi - 为什么 FileAge 返回意外的值?
- r - 在 R 中获取最近 6 个月的数据
- google-apps-script - 如何将更新日志的最新项目放在谷歌电子表格的顶部
- django - 带有 Keycloak 和 Django 的 OIDC - 缺失状态
- javascript - 只能由登录用户编辑
- express - 没有错误消息或状态,只是被重新路由回我的登录