2014-10-03 155 views
1

我recieving超時問題嘗試連接,並使用通過Java代碼查詢拉力賽的Apache的HttpClient 3.0Apache的HttpClient的處理請求時,客戶機(抓I/O異常的超時:連接超時

我做使用XMLHttpRequest的不得到這個問題。

由於主機爲https我不能將任何機器,但它是失敗的一個上重現此。難道這是一個cacerts的問題?莫不是檢查代理的方式?任何日誌建議獲取更多信息?

Tha NKS!

錯誤信息是: org.apache.commons.httpclient.HttpmethodDirector executeWithRetry INFO:I/O異常(java.net.ConnectException)處理請求時抓:連接超時:連接。

他們正在運行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(); 
} 

} }

回答