hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Tonhofer, m-plify S.A." <d.tonho...@m-plify.com>
Subject Bytes written over the 'wire' are dropped on the floor?
Date Fri, 09 Jul 2004 17:37:34 GMT
Hello,

I have spent the past few hours tracking down a problem that seems to
occur if you push bytes too quickly over a socket. As it happened with
HTTPClient, I though I might ask here. Maybe somebody has already heard
about it and can tell me whether there is a simple trick I don't know about.

First, this happens under W2K, with Sun JVM 1.4.1. Haven't tried it on
Linux yet (if anyone is interested, let me know).

The HTTPClient I use is the 2.0 version.

The HTTP Server is a simple homegrown Java socket-handling framework
it basically just reads the bytes from the InputStream that it obtains
from the socket.

Problem:
--------

If I issue HTTPClient POST requests really quickly (in this case, inside
a tight loop), then the first two request are received ok. On the third request,
the data written over the 'wire' (note that the network is not really involved,
client and server are on the same machine) seems to be dropped on the floor, i.e.
the server receives the HTTP header, the HTTP header endline, and I can see
HTTPClient log that it wrote the request body, but the request body is never
received on the server side, even if the server waits a whole minute. I have
tried to use InputStream and BufferedInputStream, but to avail.

Le fixe:
--------

What fixed the problem was the introduction of a little delay in
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpState state, HttpConnection
conn),
just before the 'flush' of the body. This (line 2322 in HttpMethodBase):

 ...
 writeRequestBody(state, conn);
 // make sure the entire request body has been sent
 conn.flushRequestOutputStream();
 ....

is 'augmented' with this:

 ...
 writeRequestBody(state, conn);
 try {
   Thread.sleep(20);
 }
 catch (Exception exe) {
 }
 conn.flushRequestOutputStream();
 ...

I think I have already encountered this problem with Java 1.2 a few years ago,
also on W2K (indeed I have found a 500ms sleep in some old code I have been keeping
around). Does anyone know if this is a common phenomenon?

Best regards and thanks in advance for any clue,

	-- David Tonhofer



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Mime
View raw message