2025/08/26 Weaviate调试记录
快两年没上这个帐号了
回来的原因是想记录一些配置/调试遇见的bug,因为内容比较零散,不适合放在个人主页。
由于需要在Linux环境下用GPU,将虚拟机卸载换成了双系统,不能再通过宿主机的虚拟网卡方式配置代理,因此出现了代理与Weaviate不兼容的问题。
具体来说,使用 connect_to_local 时会报错(截取部分):
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "failed to connect to all addresses; last error: UNAVAILABLE: ipv4:127.0.0.1:xxxxx: Socket closed"
debug_error_string = "UNKNOWN:Error received from peer {grpc_status:14, grpc_message:"failed to connect to all addresses; last error: UNAVAILABLE: ipv4:127.0.0.1:xxxxx: Socket closed"}"
le_ping_exception raise WeaviateGRPCUnavailableError( weaviate.exceptions.WeaviateGRPCUnavailableError: Weaviate v1.32.2 makes use of a high-speed gRPC API as well as a REST API. Unfortunately, the gRPC health check against Weaviate could not be completed. This error could be due to one of several reasons: - The gRPC traffic at the specified port is blocked by a firewall. - gRPC is not enabled or incorrectly configured on the server or the client. - Please check that the server address and port (localhost:50051) are correct. - your connection is unstable or has a high latency. In this case you can: - increase init-timeout in `weaviate.connect_to_local(additional_config=wvc.init.AdditionalConfig(timeout=wvc.init.Timeout(init=X)))` - disable startup checks by connecting using `skip_init_checks=True
可以看到grpc没有尝试连接正常配置的端口,而是去连接了代理端口。
对于这种情况,最开始的措施是手动指明代理
proxies = Proxies(
http="http://127.0.0.1/xxxxx/",
https="http://127.0.0.1/xxxxx/"
)
self.client = weaviate.connect_to_local( host=host, port=http_port, grpc_port=grpc_port,
additional_config=AdditionalConfig(
proxies=proxies
)
)
但是这种情况会报错(打开代理调用本地weaviate服务就会报错)
_response_dict raise UnexpectedStatusCodeError(location, response) weaviate.exceptions.UnexpectedStatusCodeError: Meta endpoint! Unexpected status code: 502, with response body: None.
因为事实上,这段代码要从python连接到本地的docker环境(http://127.0.0.1:8081),根本就不应该通过代理。
于是我通过.bashrc配置了全局的no_proxy变量,设置本地不通过代理。
但是修改.bashrc并source ~/.bashrc后,新配置只在当前终端和新打开的终端中生效。因此将终端关闭后重新打开即可。
对于这种Python本地连接Docker Weaviate本地的情况,并不需要额外在代码中(包括docker-compose.yml)中配置代理。