Frage

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?

War es hilfreich?

Lösung

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

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top