gRPCは、環境変数 http_proxy、https_proxyがセットされていると "Connect Failed" のエラーになる
python で呼ぶ時、クライアント側で
channel = grpc.insecure_channel('localhost:50051')
stub = hoge_pb2_grpc.AVRGatewayStub(channel)
response = stub.Reply(hoge_pb2.ReplyRequest(message='hoge'))
みたいに呼ぶと、
File "grpc_client.py", line 10, in run
response = stub.Reply(hoge_pb2.ReplyRequest(message='hoge'))
File "/Users/xxxxxx/anaconda/lib/python2.7/site-packages/grpc/_channel.py", line 562, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "/Users/xxxxxx/anaconda/lib/python2.7/site-packages/grpc/_channel.py", line 466, in _end_unary_response_blocking
raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "Connect Failed"
debug_error_string = "{"created":"@1555458254.922345000","description":"Failed to create subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":2715,"referenced_errors":[{"created":"@1555458254.922342000","description":"failed to connect to all addresses","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":456,"referenced_errors":[{"created":"@1555458254.922322000","description":"Connect Failed","file":"src/core/ext/filters/client_channel/subchannel.cc","file_line":963,"grpc_status":14,"referenced_errors":[{"created":"@1555458254.922221000","description":"HTTP proxy returned response code 403","file":"src/core/ext/filters/client_channel/http_connect_handshaker.cc","file_line":220}]}]}]}"
>
みたいなエラーになる。これは、http_proxyとhttps_proxyが設定されている時にlocalhostに接続しに行くとこうなるみたいで、
% unset http_proxy
% unset https_proxy
としてから実行するとエラーにならない。
python の中で対応するには、
import os
してから、
os.environ.pop('http_proxy', None)
os.environ.pop('https_proxy', None)
とすると良い。
gRPCのバージョンは、
$ pip list | grep grpc
grpc 0.3.post19
grpcio 1.20.0
grpcio-tools 1.20.0
gRPCのサンプルコードは、
を使ってます。
# ググると結構出てくるので、知っている人は知っている、という感じかな?正確には、「localhostに接続する時はエラーになる」という事なので、本当に分散環境でやる時はちゃんと考えないといけない。
Author And Source
この問題について(gRPCは、環境変数 http_proxy、https_proxyがセットされていると "Connect Failed" のエラーになる), 我々は、より多くの情報をここで見つけました https://qiita.com/tadaogi/items/891a45bf3a7d45b6009e著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .