0

I want to increase timeout to 5 minutes because one minute is not enough to receive response.

I ahve tried this two approaches:

        HttpParams httpParameters = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpParameters, 80000);
        HttpConnectionParams.setSoTimeout(httpParameters, 80000);



        DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);


        if (isNetworkAvailable()) {
            createRequest();
            HttpResponse response = httpClient.execute(request);
            final int code = response.getStatusLine().getStatusCode();

        AndroidDefaultClient client = AndroidDefaultClient.newInstance("tets");
        HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), 5* 60 *1000);
        HttpConnectionParams.setSoTimeout(httpClient.getParams(), 5* 60 *1000);

Unfortunatly the timeout remains the same, but in case when I make it smaller, e.g. 10000, it works fine. Could you please help me to figure out with this issue?

Mr Kohn Doew
  • 277
  • 1
  • 2
  • 18

2 Answers2

1

The Javadoc is incorrect on this point. The default connection timeout is platform-dependent, around a minute, and cannot be increased, only decreased.

user207421
  • 305,947
  • 44
  • 307
  • 483
0

Are you testing on an emulator? Perhaps you need to increase the adb connection timeout as mentioned here.

Or you might need to re-order your params and client code to have the params come first as talked about here.

Community
  • 1
  • 1
Adam Johns
  • 35,397
  • 25
  • 123
  • 176