android-async-http / android-async-http

An asynchronous, callback-based Http client for Android built on top of Apache's HttpClient libraries.
https://github.com/android-async-http/android-async-http#this-project-is-no-longer-maintained-and-is-currently-deprecated-and-insecure-to-use
Apache License 2.0
10.63k stars 4.09k forks source link

Server timeout error gets statusCode 0 instead of 12002 - Server timeout #764

Closed kamilwlf closed 9 years ago

kamilwlf commented 9 years ago

onFailure return int statusCode = 0(undefined error) instead of 12002 (Server timeout)

Throwable is corectly: java.net.SocketTimeoutException

fineswap commented 9 years ago

@kamilwlf Please provide source code and log tail, if applicable, for the Throwable.

kamilwlf commented 9 years ago
getClient().get("http:/xxx.net/xxx/xxx.json", new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
            }
            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {               
            }
        });
fineswap commented 9 years ago

@kamilwlf Thanks for that. Can you kindly produce a trace for the exception? And what backend system are you using, if I may ask?

kamilwlf commented 9 years ago

I have a domain which is at issue: http://api.citysdk.waag.org/

another thing is that if the server is overloaded and responds only after about a minute , the data never answered , but as traditionally tested in the browser gets the correct response, of course, after a minute but gets

getClient().setTimeout(90000);

async-http-> 60 sec server lag-> java.net.SocketTimeoutException and statusCode = 0(undefined error) browser-> 60 sec server lag-> correct response

fineswap commented 9 years ago

@kamilwlf Is the error code that you see in the browser sent by the backend system? Is it possible for you to catch a screenshot or copy-paste that error from the browser?

kamilwlf commented 9 years ago

there is no error from the browser in the browser gets all the data correctly

685 ms 593 ms...

http://tools.pingdom.com/fpt/#!/eEvcct/http://api.citysdk.waag.org/nodes?layer=divv.parking.capacity&per_page=200&geom=

->history and Previous tests for Tested Load Time Page Size Requests Page Speed December 21 20:13:31 685 ms 2.4 kB 1 100 December 8 22:12:52 593 ms 2.5 kB 1 100 December 8 13:29:02 60.00 s 0 B 1 100 December 8 12:48:20 19.58 s 2.4 kB 1 100 December 8 12:33:36 2.60 s 2.4 kB 1 100 December 8 12:33:06 35.61 s 2.4 kB 1 100 December 8 12:31:24 39.02 s 2.4 kB 1 100 December 8 12:29:54 11.92 s 2.4 kB 1 100

fineswap commented 9 years ago

@kamilwlf

Thanks for that. In the browser, and also in Pingdom, I am unable to reproduce a 60-second lag, obviously because the server isn't overloaded at the moment. So I am unable to debug the problem further.

I took a look at the source code where this '0' could come from, and I can see two places (here and here) that send '0' for the status code. The reason, obviously, is because the library cannot determine the cause of the I/O exception from the client-side point of view.

However, if you could submit a trace for the Exception, that would shed more light on this problem.

kamilwlf commented 9 years ago

the server is overloaded daily from 1 p.m to 4 p.m Europe time

Thank you for your time, the problem isn't important to me

fineswap commented 9 years ago

Alright @kamilwlf. If this becomes an issue to you, please open a ticket.