在 jodd-http(6.0.2) 中设置代理后,connectionTimeout 似乎不起作用

The connectionTimeout seems not work after setting the proxy in jodd-http(6.0.2)

这是我的代码

import jodd.http.*;
import jodd.http.net.*;
public class JoddQuestion {
    public static void main(String[] args) {
        SocketHttpConnectionProvider connectionProvider = new SocketHttpConnectionProvider();
        ProxyInfo proxyInfo = ProxyInfo.httpProxy("xxxx", xx, "xxxx", "xxxx");
        connectionProvider.useProxy(proxyInfo);

        String url = "http://www.google.com";
        HttpResponse response = HttpRequest.get(url).open(connectionProvider).connectionTimeout(1000).timeout(1000).followRedirects(true).send();
        System.out.print(response.bodyText());
    }
}

Google 网站在中国被防火墙拦截。没有设置代理,运行 程序,connectionTimeout 有效。

HttpResponse response = HttpRequest.get(url).connectionTimeout(1000).timeout(1000).followRedirects(true).send();

enter image description here

但是,设置代理后,connectionTimeout 不起作用,程序一直在尝试。

HttpResponse response = HttpRequest.get(url).open(connectionProvider).connectionTimeout(1000).timeout(1000).followRedirects(true).send();

enter image description here

open() 方法打开连接(因此应用先前 设置的超时。任何设置 after 的调用open() 将不会应用。

您可能想使用方法:withConnectionProvider() 而不是 open() - 它只会设置提供程序而不打开连接。然后在实际打开连接时将应用超时。

在此处阅读更多内容:https://http.jodd.org/connection#sockethttpconnectionprovider

或者只使用open()作为发送前的最后一个方法。但如果没有充分的理由,我会强烈避免使用 open:只需使用 send(),因为它会打开连接。

编辑:请升级到 Jodd HTTP v6.0.6 以防止评论中提到的一些不相关的问题。