You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用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服务器在同一台机器上

排查与解决方案

  1. 核对通知端口配置
    检查GridDB集群配置文件gs_cluster.json中的notificationAddress字段,确认是否设置为127.0.0.1:10001或0.0.0.0:10001。若集群绑定了其他IP,客户端需使用对应IP地址连接。

  2. 检查防火墙端口放行
    Ubuntu的ufw防火墙可能拦截10001端口,执行以下命令确认并放行:

    sudo ufw status
    sudo ufw allow 10001/tcp
    
  3. 验证版本兼容性
    确认griddb-python-client 0.8.4与GridDB 5.3.0的版本匹配性,若不兼容,升级或降级客户端至对应版本。

  4. 延长连接超时时间
    在get_store方法中添加timeout参数(单位秒),排查是否为连接延迟导致的超时:

    store = factory.get_store(
        notification_member='127.0.0.1:10001',
        cluster_name='defaultCluster',
        username='admin',
        password='admin',
        timeout=30
    )
    
  5. 查看GridDB日志定位问题
    查看GridDB日志文件(默认路径/var/lib/gridstore/log/),搜索连接相关错误信息,获取拒绝连接的具体原因。

  6. 尝试使用主机名连接
    将notification_member替换为localhost:10001,排查本地DNS解析是否存在异常。


内容的提问来源于stack exchange,提问作者Nooruddin Lakhani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 17:51:45