使用Python客户端连接本地GridDB集群时遇GSConnectionException错误求助
GridDB Python客户端连接本地集群超时(GSConnectionException)
环境详情
GridDB版本:5.3.0(社区版) Python版本:3.9 操作系统:Ubuntu 20.04 LTS griddb-python-client版本:0.8.4 集群配置:单节点开发环境
连接代码
import griddb_python as griddb factory = griddb.StoreFactory.get_instance() try: store = factory.get_store( notification_member='127.0.0.1:10001', cluster_name='defaultCluster', username='admin', password='admin' ) print("连接成功。") except griddb.GSException as e: print(f"连接失败:{e}")
错误信息
GSConnectionException: Cannot connect to GridDB cluster
已确认事项
- GridDB服务正常运行
- 集群状态为
MASTER - 集群名称确实是
defaultCluster - 用户名和密码正确
- 客户端与GridDB服务器在同一台机器上
排查与解决方案
核对通知端口配置
检查GridDB集群配置文件gs_cluster.json中的notificationAddress字段,确认是否设置为127.0.0.1:10001或0.0.0.0:10001。若集群绑定了其他IP,客户端需使用对应IP地址连接。检查防火墙端口放行
Ubuntu的ufw防火墙可能拦截10001端口,执行以下命令确认并放行:sudo ufw status sudo ufw allow 10001/tcp验证版本兼容性
确认griddb-python-client 0.8.4与GridDB 5.3.0的版本匹配性,若不兼容,升级或降级客户端至对应版本。延长连接超时时间
在get_store方法中添加timeout参数(单位秒),排查是否为连接延迟导致的超时:store = factory.get_store( notification_member='127.0.0.1:10001', cluster_name='defaultCluster', username='admin', password='admin', timeout=30 )查看GridDB日志定位问题
查看GridDB日志文件(默认路径/var/lib/gridstore/log/),搜索连接相关错误信息,获取拒绝连接的具体原因。尝试使用主机名连接
将notification_member替换为localhost:10001,排查本地DNS解析是否存在异常。
内容的提问来源于stack exchange,提问作者Nooruddin Lakhani
相关产品推荐
相关产品推荐

