I use Apache DefaultHttpClient in an Android application to receive a request to a web server (the URL does not matter, the phenomenon is visible for different servers / websites). The first request using HTC Desire with a 3G network takes a few seconds (> 4 s), and the next request takes about 0.5 s. If I wait more than 15 seconds before the next request, the next request will again take several seconds. The request uses HTTP1.1, server time is not a problem. Finding DNS is also not a problem, as I also tried to use IP.
For me, it looks like either some connection timeout parameter in the Apache infrastructure, or my HTC device, which puts the network interface into sleep mode (if it does at all).
The coding is pretty simple, it looks like this:
HttpGet get = new HttpGet(uri); long startTimeMillisRequest = System.currentTimeMillis(); HttpResponse response = client.execute(get); long endTimeMillisRequest = System.currentTimeMillis();
Does anyone have a clue to the cause or experience of the same? I already put this in AsyncTask, but still I would like to know why it is so slow.
Thanks Martin
source share