Greesh Kumar
Greesh Kumar

Reputation: 1887

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

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

Upvotes: 9

Views: 31284

Answers (1)

A4L
A4L

Reputation: 17595

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.

Upvotes: 4

Related Questions