[prev in list] [next in list] [prev in thread] [next in thread] 

List:       httpclient-users
Subject:    Re: socket write error and non repeatable request entity problem
From:       Oleg Kalnichevski <olegk () apache ! org>
Date:       2010-09-14 19:33:00
Message-ID: 1284492780.16297.3.camel () ubuntu
[Download RAW message or body]

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic