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: socket write error and non repeatable request entity problem
Date Tue, 14 Sep 2010 19:33:00 GMT
On Tue, 2010-09-14 at 19:08 +0300, George Georgieff wrote:
> I have this code:
> 
> 
> -----------------
> DefaultHttpClient httpclient = new DefaultHttpClient();
> // I want stream body, not file body
> InputStream fullStream = new BufferedInputStream(new FileInputStream(...), 8192);
> 
> 
> HttpPost method = new HttpPost("...");
> MultipartEntity entity = new MultipartEntity();
> InputStreamBody fullBody = new InputStreamBody(fullStream, "application/octet-stream",
"full-5000");
> entity.addPart("fullll", fullBody);
>         
> method.setEntity(entity);
> 
> HttpContext context = new BasicHttpContext();
> HttpResponse response = httpclient.execute(method, context);
> -----------
> 
> The first time I execute this code it returns HTTP CREATED (which is expected).
> The second time....
> 
> ...I receive on the client side:
> 
> 
> 2010-9-14 18:13:25 org.apache.http.impl.client.DefaultRequestDirector execute
> INFO: I/O exception (java.net.SocketException) caught when processing request: Software
caused connection abort: socket write error
> 2010-9-14 18:13:25 org.apache.http.impl.client.DefaultRequestDirector execute
> INFO: Retrying request
> Exception in thread "main" org.apache.http.client.ClientProtocolException
>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:643)
>         at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
>         at org...MYCLASS..WHATEVER
>         at org...MYCLASS.main()..WHATEVER
> Caused by: org.apache.http.client.NonRepeatableRequestException: Cannot retry request
with a non-repeatable request entity.  The cause lists the reason the original request failed.
> 
> 
> and on the server side:
> 
> 
> 
> java.io.IOException: Invalid chunk header
>         at com.sun.grizzly.tcp.http11.filters.ChunkedInputFilter.doRead(ChunkedInputFilter.java:169)
>         at com.sun.grizzly.tcp.http11.InternalInputBuffer.doRead(InternalInputBuffer.java:731)
>         at com.sun.grizzly.tcp.Request.doRead(Request.java:490)
>         at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:331)
>         at com.sun.grizzly.util.buf.ByteChunk.substract(ByteChunk.java:378)
>         at org.apache.catalina.connector.InputBuffer.readByte(InputBuffer.java:343)
>         at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:161)
>         at javax.servlet.ServletInputStream.readLine(ServletInputStream.java:133)
>         at org.apache.catalina.connector.CoyoteInputStream.readLine(CoyoteInputStream.java:277)
>         at com.oreilly.servlet.multipart.MultipartParser.readLine(MultipartParser.java:466)
>         at com.oreilly.servlet.multipart.MultipartParser.(MultipartParser.java:205)
>         at com.oreilly.servlet.multipart.MultipartParser.(MultipartParser.java:121)
> 
> 
> After I restart my IDE this problem disappears (but it should not be there in the first
place).
> Do constructors of objects of the httpclient lib maintain GLOBAL STATIC DATA ?????????
> 

No they do not.

> So what is that invalid chunk header ? Is there a problem in the multipart parser I use?
> Or is there a problem with my code, or god forbid, HttpClient ?
> 
> 

Apparently Grizzly (GlassFish?) thought some of the body chunks was
malformed and dropped the connection. You can see whether or not this is
the case by using a packet sniffer or wire logging feature of HttpClient

http://hc.apache.org/httpcomponents-client-ga/logging.html

Oleg



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


Mime
View raw message