Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve org.apache.http.conn.ConnectTimeoutException in Http Request to another server?

Tags:

java

I am using HttpClient to handling http requests and when I try to contect with my target server I am getting a error as

org.apache.http.conn.ConnectTimeoutException: Connect to prdalonegk.alonegk.com:9090 timed out

where prdalonegk.alonegk.com:9090 is my xmpp server

like image 651
Greesh Kumar Avatar asked Aug 10 '15 08:08

Greesh Kumar


1 Answers

Make sure the host prdalonegk.alonegk.com is reacheable

ping prdalonegk.alonegk.com

and that it is can accept connections on port 9090 (firewall).

If all is ok, then try to increase the connection timeout:

RequestConfig.Builder requestBuilder = RequestConfig.custom();
requestBuilder = requestBuilder.setConnectTimeout(3000L); /* in ms */

Please refere to the request builder javadocs for all the settings you may provide.

like image 113
A4L Avatar answered Oct 09 '22 00:10

A4L