I am while using Apache DefaultHttpClient within an Android application to create a get request to some webserver (URL does not matter, the phenomenon is viewed for various servers/websites). The very first request while using Htc Desire Mobile Phone using the 3rd generation network takes several seconds (>4s), subsequent ones roughly only .5s. Basically wait a lot more than ~just a few seconds prior to making the following request, this next request again needs several seconds. The request is applying HTTP1.1, the server time isn't the problem. DNS research can also be not the issue, when i attempted while using IP too.

For me personally it appears like either some connection timeout establishing the Apache framework or my HTC device putting the network interface to rest (whether it performs this whatsoever).

The coding is fairly simple, it appears such as this:

HttpGet get = new HttpGet(uri);
long startTimeMillisRequest = System.currentTimeMillis();
HttpResponse response = client.execute(get);
long endTimeMillisRequest = System.currentTimeMillis();

Does anybody possess a clue for that reason or go through the same factor? I already put this into an AsyncTask, but nonetheless Let me know why it is primarily the slow.

Thanks, Martin

You will find a few options here:

  • Keepalives: It may be it's costly to setup the first TCP connection then re-using the tcp connection for subsequent http demands. This describes the tcp connection being dropped after ~10-just a few seconds forcing you to definitely re-initiate them

  • DNS cache expiry - most unlikely since we're speaking of seconds rather than minutes.

The very best factor to complete is always to setup tcpdump and capture packets. This can be done by taking the packets inbound in your server and getting phone tcp stream.

@Martin, Basically ve not misinterpreted, exactly what do u expect may be the http 1.1 pipeling behavior. If so android http cliend doesn't support it. I ve exactly the same problem. There's an problem open around the android bugtrack website.