在使用pymilvus客户端代码去连接milvus容器服务时,有时会出现连接超时失败的情况,异常如下:
Traceback (most recent call last):
File “/home/xxx/.local/lib/python3.10/site-packages/pymilvus/client/grpc_handler.py”, line 111, in _wait_for_channel_ready
grpc.channel_ready_future(self._channel).result(timeout=timeout)
File “/home/xxx/.local/lib/python3.10/site-packages/grpc/_utilities.py”, line 139, in result
self._block(timeout)
File “/home/xxx/.local/lib/python3.10/site-packages/grpc/_utilities.py”, line 85, in _block
raise grpc.FutureTimeoutError()
grpc.FutureTimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/home/xxx/source2023/milvus-example/reverse_image_search/my.py”, line 77, in
connections.connect(host=HOST, port=PORT)
File “/home/xxx/.local/lib/python3.10/site-packages/pymilvus/orm/connections.py”, line 303, in connect
connect_milvus(**kwargs, user=user, password=password)
File “/home/xxx/.local/lib/python3.10/site-packages/pymilvus/orm/connections.py”, line 274, in connect_milvus
gh._wait_for_channel_ready(timeout=timeout)
File “/home/xxx/.local/lib/python3.10/site-packages/pymilvus/client/grpc_handler.py”, line 114, in _wait_for_channel_ready
raise MilvusException(Status.CONNECT_FAILED,
pymilvus.exceptions.MilvusException: <MilvusException: (code=2, message=Fail connecting to server on 127.0.0.1:19530. Timeout)>
今天终于复现了现象:

  1. 在Ubuntu中开启网络代理,然后打开终端,启动milvus相关容器服务。在另一个新开的终端中连接milvus服务,就会出现如上异常。
  2. 在Ubuntu中关闭网络代理,然后重新打开终端,启动milvus相关容器服务,在另一个新开的终端中连接milvus服务,就可以正常连接。
    所以,总结一下,连接超时问题还是受到了网络代理的影响。
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐