You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by httpClientUser <ki...@mindtree.com> on 2011/03/03 11:20:24 UTC

Re: Getting MalformedChunkCodingException while downloading attachments



olegk wrote:
> 
> On Mon, 2011-02-28 at 04:27 -0800, httpClientUser wrote:
>> Hi All,
>> 
>> I am using HttpClient4.1 and jdk1.6.0_16, I am trying to download more
>> than
>> 1000 attachments using HttpClient in a program.
>> 
>> I used ThreadSafeClientConnManager for creating the connectionManager.
>> When
>> i try downloading attachments and persisting the stream to DB, few are
>> failing with the following error
>> 
>> Caused by: org.apache.http.MalformedChunkCodingException: Unexpected
>> content
>> at the end of chunk at
>> org.apache.http.impl.io.ChunkedInputStream.getChunkSize(ChunkedInputStream.java:239)
>> at
>> org.apache.http.impl.io.ChunkedInputStream.nextChunk(ChunkedInputStream.java:204)
>> at
>> org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:167)
>> at
>> org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:196)
>> at
>> org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:155)
>> 
>> Actual piece of code for creation of HttpClient instance is:
>> 
>> SchemeRegistry schemeRegistry = new SchemeRegistry();
>> schemeRegistry.register(new Scheme("http",
>> workspaceMigrationConfigBean.getHttpPort(),
>>             PlainSocketFactory.getSocketFactory()));
>> ClientConnectionManager cm = new
>> ThreadSafeClientConnManager(schemeRegistry);
>> HttpClient client = new DefaultHttpClient(cm);
>> 
>> If i retry to download only those failed attachments, they are persisted
>> properly. This issue is intermittent.
>> 
>> What could be the possible issue? Please help me.
>> 
>> Thanks in advance, 
>> KiranKumar S.
>> 
> 
> 
> Try running your code with wire logging enabled and see if data chunks
> sent by the server are valid or not. See if there is some trailing data
> at the end of the chunks, that is, if the actual length of a data chunk
> is larger than the number stated in the chunk header.
> 
> Oleg
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 
Hi Oleg,

Thanks for your suggestion and i will try to do wire logging. 
As i mentioned earlier this issue is intermittent and i am downloading the
files 
using HttpClient's ThreadSafeClientConnManager.

Please let me know, is program bad or HttpClient has any issue with
ThreadSafeClientConnManager enabled?
-- 
View this message in context: http://old.nabble.com/Getting-MalformedChunkCodingException-while-downloading-attachments-tp31030430p31057585.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


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