V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Elaina
V2EX  ›  程序员

关于 Datagrip 无法连接数据库而 Navicat 可以连接的问题

  •  
  •   Elaina · 31 天前 · 2004 次点击

    现在的网络是这样的,有一台服务器,配置好了 zerotier 。 然后使用 zerotier 的 ip ,远程连接数据库,zerotier 提供的 ip 段是 172.31.xx.xx 。

    当我使用了 surge 的系统代理+增强模式( tun 模式)之后,Datagrip 就无法连接远端数据库了,但是 Navicat 可以,当关掉 surge 之后,Datagrip 才能顺利连接,这个有什么解决办法吗?

    使用 surge 的请求查看器观察到是匹配的直连规则,但花费了 10s 才建立连接,但是我 ping 这个 ip 只有 30-40ms ,ssh 之类的速度也很快。

    1.png

    以及 Datagrip 报错是这样的,但这个错误提示好像并没有任何信息量。 2.png

    求 v 友们指点一下,有什么解决办法吗?

    27 条回复    2024-03-30 20:37:20 +08:00
    moshiyeap100
        1
    moshiyeap100  
       31 天前
    点一下 Test Connection 看看连接信息里的 PING 是多少
    moshiyeap100
        2
    moshiyeap100  
       31 天前
    我在想是不是走了 GEOIP 判定了,看看有没有类似的规则
    moshiyeap100
        3
    moshiyeap100  
       31 天前
    在请求查看器里看看连接的 Timing/Note ,截个图看看
    jaoyina
        4
    jaoyina  
       31 天前
    这个错并不像是网不通,看下驱动和连接参数有什么差异。
    Starxy
        5
    Starxy  
       31 天前
    之前 mysql 遇到过类似的 dg 连不上 navicat 能连上的问题,当时也在用 zt ,但是 surge 没用过,最后是 vm 参数加了-Djava.net.preferIPv4Stack=true 解决的
    chen90902
        6
    chen90902  
       31 天前 via iPhone
    之前我也遇到过类似的情况,排查出来是开了代理的问题,可以关闭代理试试。

    有环境变量可以忽略代理,搜一下吧
    Elaina
        7
    Elaina  
    OP
       31 天前
    @moshiyeap100
    好像 test connection 的信息没有 ping 值,
    这个 surge 是信息,看着是没有匹配到 GEOIP 的地方,
    ![3.png]( https://s2.loli.net/2024/03/30/HaYqmnisgdkWVJI.png)
    Rule Evaluating - 2 ms

    Events
    13:53:07.784155 [Connection] Incoming proxy protocol: SOCKS
    13:53:07.787155 [Rule] Sub-rule matched: IP-CIDR 172.16.0.0/12(Direct.list)
    13:53:07.787215 [Rule] Rule matched: RULE-SET Direct.list
    13:53:07.789037 [Socket] Connecting with address: 172.30.245.40, bound to the primary interface (en0) explicitly under Enhanced Mode
    13:53:12.794170 [Connector] Set up backup connection #2
    13:53:12.794873 [Socket] Connecting with address: 172.30.245.40, bound to the primary interface (en0) explicitly under Enhanced Mode
    13:53:17.794880 [Connection] Disconnect with reason: Closed by client
    Elaina
        8
    Elaina  
    OP
       31 天前
    @Starxy vm 上加了这玩意儿还是不行,很离谱
    Elaina
        9
    Elaina  
    OP
       31 天前
    @jaoyina 参数我开始以为是 ssl 的问题,把 ssl 改成了 false 还是不行
    Elaina
        10
    Elaina  
    OP
       31 天前
    @moshiyeap100 能定位的问题是关闭增强模式就能正常连接了,开启的话直接提示连接失败。这个是什么原理呢
    moshiyeap100
        11
    moshiyeap100  
       31 天前
    @Elaina [Rule] Sub-rule matched: IP-CIDR 172.16.0.0/12(Direct.list) 把这个 Direct.list 中的规则关于 172.16.0.0/12 的规则干掉试试
    Elaina
        12
    Elaina  
    OP
       31 天前
    @moshiyeap100 干掉了还是连不上,虽然走的是我梯子的规则,surge 那里 50ms 就成功了,上面那个得 10s😂
    Elaina
        13
    Elaina  
    OP
       31 天前
    @moshiyeap100 我排查出问题了,是开了 socks 代理之后,jdbc 会出问题,这个有解决方法吗?
    parthenon2007
        14
    parthenon2007  
       31 天前 via iPhone
    我也是同样的问题。
    rm0gang0rf
        15
    rm0gang0rf  
       31 天前
    socks 代理关掉就行了
    moshiyeap100
        16
    moshiyeap100  
       31 天前
    @Elaina datagrip 的配置页面,就是你截图的这个页面,connect type 选 default 或者 unix socket 试试
    Elaina
        17
    Elaina  
    OP
       31 天前
    @moshiyeap100 default 和 url 都试过了,不行,不知道这个 socks 有啥坑😂,头疼
    Elaina
        18
    Elaina  
    OP
       31 天前   ❤️ 1
    @moshiyeap100 我调试出来了,把 host 加到这个列表里面:TCP Force HTTP Hosts ,就可以连接了,不知道为啥,很怪
    moshiyeap100
        19
    moshiyeap100  
       31 天前
    @Elaina 晚上回家我也研究下,上次我用 tun 模式也遇到了类似的问题,不过我当时改了下规则就可以用了。
    zzping
        20
    zzping  
       31 天前
    Datagrip 无法连接 startrocks ,但 Navicat 能,有什么好的解法吗
    ChicC
        21
    ChicC  
       31 天前
    可能是使用了 Datagrip 的 socks 代理?用 http 代理试试
    infun
        22
    infun  
       31 天前
    在 DBeaver 里面遇到过 复制后修改的连不上,完全新建的可以
    楼主是复制的吗?
    Elaina
        23
    Elaina  
    OP
       31 天前
    @infun 我是手填的
    Elaina
        24
    Elaina  
    OP
       31 天前
    @ChicC 有可能是这个原因,我在 http proxy 选项里面看到了这个警告:
    ```
    You have JVM property "https.proxyHost" set to "127.0.0.1".This may lead to incorrect behaviour. Proxy should be set in Settings HTTP ProXyThis JVM property is old and its usage is not recommended by Oracle.(Note: lt could have been assigned by some code dynamically.
    ```
    难道是这玩意儿的锅😂
    ChicC
        25
    ChicC  
       31 天前
    @Elaina 他家软件配置的代理会导致所有连接都走那个代理
    Elaina
        26
    Elaina  
    OP
       30 天前
    @ChicC 但是我在 vm 的配置里删掉了这个,然后选 no Proxy ,不关掉本机的 socks 代理仍然无法连接,感觉像是环回了? Datagrip->虚拟网卡->zerotier->虚拟网卡?因为外网的服务器连接并没有问题,就是使用 zerotier 的内网服务器才会有这个问题
    ChicC
        27
    ChicC  
       30 天前
    @Elaina Tun 了就复杂了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2581 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 12:26 · PVG 20:26 · LAX 05:26 · JFK 08:26
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.