Monday, December 28, 2009

[android-developers] Tomcat httppost bufferedreader problem

Hi

My (client)application connects to a Tomcat server through http post
requests.
My problem is that the application sometimes does not get the complete
response.
The last X bytes are missing.
The length of a response is, however, below 1K (did not count or
measure it).

My application retrieves data from the Tomcat server at various
moments in time. I also have a PC version of the application that has
exactly the same code-base for this part. On the PC there is not a
problem.
Also, it does not happen all the time. I cannot pinpoint when it goes
right and when wrong.
It seems like a timing problem.

I tried several things to solve the problem. This ranges from reading
the result of the post two times to letting the thread sleep at
various places in the code.
None of the solutions are a silver bullets, although the problem seems
less frequent.

So maybe I'm doing something wrong.

Did somebody have a similar problem?
Should I post requests, or readout the response in a different way?

My code is as follows:

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;

HttpPost httpost = new HttpPost(aUrl);
HttpResponse response = RL.getHttpClient().execute(httpost);
HttpEntity entity = response.getEntity();

if (entity != null) {
br = new BufferedReader(new InputStreamReader(entity.getContent
())) ;
} else {
br = null ;
}

BufferedReader is read out by using the method readLine()

Any help is appreciated.

Regards,

Maurice

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate