hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: [4.0] How does HttpClient handle 'Unexpected end of file from server' errors?
Date Mon, 12 Oct 2009 18:36:57 GMT
Andrew Thorburn wrote:
> I'm currently using some legacy code which sends/receives XML from one
> of our partners. While this normally works just fine, we've recently
> been getting errors of the form "java.net.SocketException: Unexpected
> end of file from server". I have no idea why they're occurring, and I
> haven't been able to duplicate them in my testing environment. Now,
> while I'd like to migrate to HttpClient (or something. Anything's
> better than what we have now...), I first need to know what it does in
> the case of this type of error. Does it throw an exception? Or does it
> attempt to retry the request with some (configurable?) number of
> attempts? Or something entirely different?
> I would just put in some code and test, but I haven't been able to
> replicate the error in one of our test environments, and the only one
> which is showing them is a client-facing one (not Production, but
> close).
> Also, while I'm on the subject, if anyone can suggest to me how to
> create this sort of error (I'm running Ubuntu 9.04) so I can check how
> well our program handles them. Wouldn't solve the problem, but at
> least I'd have something to test against...
> Many thanks,
> - Andrew Thorburn


I _suppose_ "java.net.SocketException: Unexpected end of file from 
server" is thrown by the internal JRE HTTP client when it encounters a 
malformed HTTP message, most likely the one where the value of the 
Content-Length header does not correspond to the effective length of the 
content entity. This is very likely a server side issue. The target 
server either (1) miscalculated the Content-Length value or (2) aborts 
the connection prematurely without sending the complete content entity.

At the very least HttpClient will give you a better error message and 
ability to examine the exact HTTP packets sent across the wire.


To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

View raw message