문제

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?

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top