Archery icon indicating copy to clipboard operation
Archery copied to clipboard

MongoDB不支持ssh tunnel模式

Open zhengxu4869 opened this issue 7 months ago • 5 comments

重现步骤

mongo实例连接隧道后,点测试或者查询都会超时。但是观察mongodb本身的log发现是认证成功的。 目前测了版本1.9.1和1.12.0都有这个问题 同样的隧道配置,mysql和psql测试下来无任何问题。

预期外的结果

gateway Time-out

日志文本


版本

1.9.1

部署方式

K8S

是否还有其他可以辅助定位问题的信息?比如数据库版本等

No response

zhengxu4869 avatar May 27 '25 08:05 zhengxu4869

也遇到了这个问题,翻看Pull requests 有人提交了解决方案 https://github.com/hhyo/Archery/pull/2652

Tieger avatar May 27 '25 12:05 Tieger

mongo.py中所有调用get_connection的function我都添加了self.close()后,测试和sql上线没问题了。

但是在线查询的话,表结构可以正常显示,点了sql查询页面会一直卡住不返回查询结果,但是点回去查询历史,能正常显示历史

Image

zhengxu4869 avatar May 28 '25 10:05 zhengxu4869

(v1.12.0)该问题修改mongo.py后解决:

  1. get_connection需要设置directConnection=true
    def get_connection(self, db_name=None):
        self.db_name = db_name or self.instance.db_name or "admin"
        auth_db = self.instance.db_name or "admin"
        if self.user and self.password:
            self.conn = pymongo.MongoClient(
                self.host,
                self.port,
                username=self.user,
                password=self.password,
                authSource=auth_db,
                connect=True,
                connectTimeoutMS=10000,
                directConnection=True,
            )
        else:
            self.conn = pymongo.MongoClient(
                self.host,
                self.port,
                authSource=auth_db,
                connect=True,
                connectTimeoutMS=10000,
                directConnection=True,
            )

        return self.conn
  1. 所有调用get_connection的funciton在最后return之前添加self.close()

zhengxu4869 avatar Jun 04 '25 08:06 zhengxu4869

修改后mongo使用tunnel模式可以正常查询,但是update看起来还有问题,后续应该会修复https://github.com/hhyo/Archery/pull/2970

zhengxu4869 avatar Jun 04 '25 08:06 zhengxu4869

目前没有进展

bwcxyk avatar Dec 08 '25 05:12 bwcxyk