[英]Apache httpclient timeout on customers machine (I/O Exception caught when processing request: Connection timed out
I'm recieving a timeout issue attempting to connect to and query Rally via Java code using Apache HttpClient 3.0 我收到尝试使用Apache HttpClient 3.0通过Java代码连接并查询Rally的超时问题
I do not get this issue using xmlhttprequest. 我没有使用xmlhttprequest得到这个问题。
I cannot reproduce this on any machine but the one that it is failing on. 我无法在任何机器上重现此错误,但是它正在失败。 Could this be a cacerts issue since the host is https? 由于主机是https,这可能是cacerts问题吗? Could there be a way to check for proxies? 有没有办法检查代理? Any logging suggestions to get more info? 任何记录建议以获取更多信息?
Thanks! 谢谢!
Error message is: org.apache.commons.httpclient.HttpmethodDirector executeWithRetry INFO: I/O exception (java.net.ConnectException) caught when processing request: connection timed out: connect. 错误消息是:org.apache.commons.httpclient.HttpmethodDirector executeWithRetry信息:处理请求:连接超时:连接时捕获到I / O异常(java.net.ConnectException)。
They are running java jdk 1.6. 他们正在运行Java JDK 1.6。
protected String doGet(HttpClient httpClient, GetMethod getMethod)
throws IOException
{
httpClient.getState().setCredentials(new AuthScope(this.host, this.port, null), new UsernamePasswordCredentials(this.username, this.password));
httpClient.getParams().setParameter("http.socket.timeout", new Integer(1000000));
getMethod.setDoAuthentication(true);
getMethod.getParams().setParameter("http.socket.timeout", new Integer(1000000));
getMethod.addRequestHeader("X-RallyIntegrationName", this.integrationName);
getMethod.addRequestHeader("X-RallyIntegrationVendor", this.integrationVendor);
getMethod.addRequestHeader("X-RallyIntegrationVersion", this.integrationVersion);
//getMethod.addRequestHeader("X-RallyIntegrationOS", getOSInfo());
//getMethod.addRequestHeader("X-RallyIntegrationPlatform", getProductInfo());
getMethod.addRequestHeader("X-RallyIntegrationLibrary", "Apache Commons HTTP Client 3.0");
try
{
double timeBefore = System.currentTimeMillis() / 1000;
int result = httpClient.executeMethod(getMethod);
double timeAfter = System.currentTimeMillis() / 1000;
System.out.println("Seconds to query for Workspace: " + (timeAfter - timeBefore));
if (result != 200) {
throw new IOException("Http GET Failed" + getMethod.getStatusLine());
}
String response = getMethod.getResponseBodyAsString();
System.out.println(response);
return response;
}
finally
{
getMethod.releaseConnection();
}
} } }}
Can you use the Rally REST Toolkit for Java: https://github.com/RallyTools/RallyRestToolkitForJava 您可以使用Java的Rally REST工具包吗: https : //github.com/RallyTools/RallyRestToolkitForJava
This handles a ton of the code you have written above (and is built using a newer version of the Apache Http Components- 4.2.x) 这处理了您上面编写的大量代码(并且是使用Apache Http Components 4.2.x的较新版本构建的)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.