1

Sometimes my server doesn't work and HttpClient tries to connect about 180 seconds before connection is refused. Is there any way to shorten this time?

CharlesB
  • 86,532
  • 28
  • 194
  • 218
Mariusz
  • 1,907
  • 3
  • 24
  • 39
  • 1
    your tag is ambiguous, please select the right one (see on tag hover info) – CharlesB Sep 17 '12 at 21:21
  • I found clear answer is : [here][1] [1]: http://stackoverflow.com/questions/693997/how-to-set-httpresponse-timeout-for-android-in-java – Mariusz Sep 17 '12 at 21:57

2 Answers2

1

This should work on android:

int socketTimeoutMS = 120000;
new DefaultHttpClient().getParams().setIntParameter("SO_TIMEOUT", socketTimeoutMS);
0

Try setting the timeout value?

Integer timeoutMs = new Integer(5 * 1000); messageSender.getHttpClient().getParams().setSoTimeout(timeoutMs);

cam
  • 778
  • 6
  • 9
  • also see here: http://stackoverflow.com/questions/132326/with-apache-httpclient-why-isnt-my-connection-timeout-working?rq=1 – cam Sep 17 '12 at 21:26
  • Apache HttpParams in Android hasn't got method setSoTimeout(timeoutMs). It is my fault that my tag was ambiguous. Thank you for help. – Mariusz Sep 17 '12 at 22:01