[android-developers] Re: HTTPClient post delay

2010-11-16 Thread SImplyG2010
Hey Kostya

It's the same result with IP address also I should point out it is way
faster on an N1 running 2.2 than it is on an emulator or physical
device (hero) running 2.1.

On Nov 16, 10:33 am, Kostya Vasilyev kmans...@gmail.com wrote:
 Just to take a guess: DNS ?

 What happens if you use the IP address in the url, rather than server name?

 -- Kostya

 16.11.2010 18:31, SImplyG2010 пишет:









  Good morning everyone,

  I am having a hugely annoying issue with delays using HTTPClient and
  post the first time I call execute on the client the response takes 5
  seconds to come back. Subsequent calls take around 100 to 200 ms. I am
  using the Apache client so does anyone know why this takes so long?
  The client setup looks like below

  HttpParams params2 = new BasicHttpParams();
  params2.setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
  HttpVersion.HTTP_1_1);
  params2.setParameter(CoreConnectionPNames.TCP_NODELAY, true);
  params2.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET,
  HTTP.UTF_8);
  params2.setParameter(CoreProtocolPNames.USER_AGENT, Apache-HttpClient/
  Android);
  params2.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 15000);
  params2.setParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK,
  false);
  HttpClient client = new DefaultHttpClient(params2);

  // params are a bunch of post params about 5 of them.

  HttpPost post = new HttpPost(baseURL);
  post.setEntity(getPostContent(params));
  client.execute(post);

  The timing for this look like below.

  11-16 08:10:50.709: VERBOSE/SG Log verb(332): Call complete 5753
  11-16 08:10:50.979: VERBOSE/SG Log verb(332): Call complete 271
  11-16 08:10:51.099: VERBOSE/SG Log verb(332): Call complete 114
  11-16 08:10:51.319: VERBOSE/SG Log verb(332): Call complete 221
  11-16 08:10:51.419: VERBOSE/SG Log verb(332): Call complete 97
  11-16 08:10:51.579: VERBOSE/SG Log verb(332): Call complete 165
  11-16 08:10:51.689: VERBOSE/SG Log verb(332): Call complete 106
  11-16 08:10:51.849: VERBOSE/SG Log verb(332): Call complete 161

  Any help is much appreciated!

 --
 Kostya Vasilyev -- WiFi Manager + pretty widget 
 --http://kmansoft.wordpress.com

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: HTTPClient post delay

2010-11-16 Thread SImplyG2010
Daniel what do you use instead? The weird thing is that the timings
shown above are purely for the execute call not the creation of the
client object or anything.

On Nov 16, 11:09 am, Daniel Drozdzewski daniel.drozdzew...@gmail.com
wrote:
 On Tue, Nov 16, 2010 at 3:31 PM, SImplyG2010

 thomas.sheppar...@gmail.com wrote:
  Good morning everyone,

  I am having a hugely annoying issue with delays using HTTPClient and
  post the first time I call execute on the client the response takes 5
  seconds to come back. Subsequent calls take around 100 to 200 ms. I am
  using the Apache client so does anyone know why this takes so long?
  The client setup looks like below

 Did you look at DDMS, what happens, when you cause the first call?
 I never used HttpClient. Since it does a lot, it probably is a bit
 heavy, so class loading and instantiating could take time.
 Once in memory it simply works.

 It is just a stab in the darkness.

 --
 Daniel

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: HTTPClient post delay

2010-11-16 Thread Daniel Drozdzewski
On Tue, Nov 16, 2010 at 4:22 PM, SImplyG2010
thomas.sheppar...@gmail.com wrote:
 Daniel what do you use instead? The weird thing is that the timings
 shown above are purely for the execute call not the creation of the
 client object or anything.


Thomas,

What I meant was that I have not been using HttpClient much in my
app(s). Used it for one activity that was much easier to achieve as a
web view and never looked at its performance.

To be sure about your times, try snooping on the network traffic just
to see, how quickly your POST gets down the wire... This will require
emulator and a traffic capture tool, like Wireshark.

You should see whether there is a noticeable delay between first call
and data being actually sent.

Also, could it be possible that your server is implemented, so that it
needs warming up? Maybe you test it locally with server restarts
between various tests?

Either way, as soon as you can establish rough delays between data
actually sent and data actually received, then you will know, whether
the problem is with your app or somewhere external.

-- 
Daniel Drozdzewski

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: HTTPClient post delay

2010-11-16 Thread SImplyG2010
I had a look using wireshark it seems in between execute being called
and the post being sent over the network is  1 second so it seems the
delay is in the execute call. Anyone know why this might be?

On Nov 16, 12:17 pm, Daniel Drozdzewski daniel.drozdzew...@gmail.com
wrote:
 On Tue, Nov 16, 2010 at 4:22 PM, SImplyG2010

 thomas.sheppar...@gmail.com wrote:
  Daniel what do you use instead? The weird thing is that the timings
  shown above are purely for the execute call not the creation of the
  client object or anything.

 Thomas,

 What I meant was that I have not been using HttpClient much in my
 app(s). Used it for one activity that was much easier to achieve as a
 web view and never looked at its performance.

 To be sure about your times, try snooping on the network traffic just
 to see, how quickly your POST gets down the wire... This will require
 emulator and a traffic capture tool, like Wireshark.

 You should see whether there is a noticeable delay between first call
 and data being actually sent.

 Also, could it be possible that your server is implemented, so that it
 needs warming up? Maybe you test it locally with server restarts
 between various tests?

 Either way, as soon as you can establish rough delays between data
 actually sent and data actually received, then you will know, whether
 the problem is with your app or somewhere external.

 --
 Daniel Drozdzewski

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: HTTPClient post delay

2010-11-16 Thread Hal

We are not getting that type of delay. You may to try   URLConnection.
Just a thought .
The following is an example.

// Post request

private String doPost (String request) {
URLConnection urlConn;
URL destURL;
DataOutputStream outStream;
DataInputStream inStream;
int c;
StringBuffer sBuffer = new StringBuffer ();

if (request == null)
return null;

if (url == null)
return null;

handleTrace (request: + request);

try {

destURL = new URL (url);

urlConn = destURL.openConnection();
urlConn.setDoOutput(true);
urlConn.setDoInput(true);



urlConn.setRequestProperty(Content-length,
 + request.length());

outStream = new DataOutputStream (urlConn.getOutputStream());

outStream.writeBytes(request);

outStream.close ();

inStream = new DataInputStream (urlConn.getInputStream());

while ((c = inStream.read()) = 0) {
sBuffer.append((char) c);
}
} catch (Exception ex) {
handleException (ex);
}

return ((String) sBuffer.toString());

}

This is taken from the Jt.JtURL component invoke by Jt.JtHttpAdapter.
It seems to have a better response time.



On Nov 16, 11:22 am, SImplyG2010 thomas.sheppar...@gmail.com wrote:
 Daniel what do you use instead? The weird thing is that the timings
 shown above are purely for the execute call not the creation of the
 client object or anything.

 On Nov 16, 11:09 am, Daniel Drozdzewski daniel.drozdzew...@gmail.com
 wrote:

  On Tue, Nov 16, 2010 at 3:31 PM, SImplyG2010

  thomas.sheppar...@gmail.com wrote:
   Good morning everyone,

   I am having a hugely annoying issue with delays using HTTPClient and
   post the first time I call execute on the client the response takes 5
   seconds to come back. Subsequent calls take around 100 to 200 ms. I am
   using the Apache client so does anyone know why this takes so long?
   The client setup looks like below

  Did you look at DDMS, what happens, when you cause the first call?
  I never used HttpClient. Since it does a lot, it probably is a bit
  heavy, so class loading and instantiating could take time.
  Once in memory it simply works.

  It is just a stab in the darkness.

  --
  Daniel

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en