每次遇到read time out异常时就一直是请求状态,通过命令jstack查看发现线程发生了read time out异常,但是程序却无法抛出。请问一下各位大牛这是怎么回事啊。

解决方案 »

  1.   

    设置代理是通过System和Authenticator来设置的和httpclient没啥关系, 看看是不是使用方式有问题.
    下面是java中设置代理的方法,根据代理支持http还是https自己改
    Authenticator.setDefault(new Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(账号, new String(密码).toCharArray());
        }
    });
    // 支持https
    System.setProperty("https.proxySet", "true");
    System.getProperties().put("https.proxyHost", IP);
    System.getProperties().put("https.proxyPort", 端口);
    // 支持http
    System.setProperty("http.proxySet", "true");
    System.getProperties().put("http.proxyHost", IP);
    System.getProperties().put("http.proxyPort", 端口);