英文:
python grpc DNS resolution failed
问题
我一直在尝试连接到一个托管在域名“example.com/server”后面的 gRPC 服务器。
我正在使用 grpc.secure_channel 来建立连接。然而,我遇到了错误消息 DNS 解析失败,example.com/server: 未知错误: 名称或服务未知
。有趣的是,如果我将域名更改为只是“example.com”,连接就会正常工作。看起来 GRPC_DNS_RESOLVER
无法解析包含主机名后的目录路径的域名。
有人在之前遇到过这个问题吗,或者有任何关于如何解决它的建议吗?
英文:
I have been attempting to connect to a gRPC server hosted behind the domain name "example.com/server".
I am using grpc.secure_channel to establish the connection. However, I encounter the error message DNS resolution failed for example.com/server: UNKNOWN: Name or service not known
. Interestingly, if I change the domain name to just "example.com", the connection works fine. It seems that the GRPC_DNS_RESOLVER
is unable to resolve domain names that include a directory path after the hostname.
Has anyone encountered this issue before or have any suggestions on how to resolve it?
channel_credential = grpc.ssl_channel_credentials(crt.encode())
channel = grpc.secure_channel('example.com/server', channel_credential)
intercept_channel = grpc.intercept_channel(channel)
stub = project_pb2_grpc.MyStub(intercept_channel)
stub.task()
答案1
得分: 1
gRPC不使用路径,您只需提供服务器名称。
英文:
gRPC does not use paths, you should only provide the server name.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论