This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Servlets and the fly likes urgent help - Connection reset by peer: socket write error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "urgent help - Connection reset by peer: socket write error" Watch "urgent help - Connection reset by peer: socket write error" New topic

urgent help - Connection reset by peer: socket write error

mudit khandelwal

Joined: Sep 28, 2004
Posts: 1
Strangely and unluckily, I have a problem that's happening only in PRODUCTION env and not on DEVELOPMENT/CERT :-(

When I make an Http request to a server (using and URLConnection classes) which sends a pdf as a response, I get the response and read it in a BufferedInputStream. Then in order to display the pdf on my browser, am trying to write bytes to ServletOutputStream using byte array:
bis is the BufferedInputStream;

byte[] buff = new byte[1024];
int bytesRead;
while (-1 != (bytesRead =, 0, buff.length))){
out.write(buff, 0, bytesRead);

Many a times it works properly and the pdf is rendered but sometimes I get ' Connection reset by peer: socket write error' exception while trying to write to the ServletOutputStream in the while loop - out.write(buff, 0, bytesRead);

(Am using weblogc 8.1 sp2)

error log: Connection reset by peer: socket write error
at Method)
at weblogic.servlet.internal.ChunkUtils.writeChunkTransfer(
at weblogic.servlet.internal.ChunkUtils.writeChunks(
at weblogic.servlet.internal.ChunkOutput.flush(
at weblogic.servlet.internal.ChunkOutput.checkForFlush(
at weblogic.servlet.internal.ChunkOutput.write(
at weblogic.servlet.internal.ChunkOutputWrapper.write(
at weblogic.servlet.internal.ServletOutputStreamImpl.write(
at tavant.olympus.common.utils.ServletHelper.writeToServletOutputStream(
at tavant.olympus.base.GenericRetrievalServlet.sendRequestAndPrintTheResponse(

at tavant.olympus.base.GenericRetrievalServlet.doPost(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at weblogic.servlet.internal.ServletStubImpl$
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(
at weblogic.servlet.internal.WebAppServletContext$
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(
at weblogic.servlet.internal.ServletRequestImpl.execute(
at weblogic.kernel.ExecuteThread.execute(

Any kinna help will be highly appreciated !!
Thanx in advance.
Vijay Vaddem
Ranch Hand

Joined: Feb 13, 2004
Posts: 243

Please go through the below given link. Could be helpful to you...

Connection Reset

Go through the response given by Kartik Ruppa and the link being provided.

yerri swamy moke

Joined: Jan 30, 2009
Posts: 1

I am also facing same issue, please give me the solution for this issue.
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

The same issue? So you are using WebLogic v8.1 and are streaming a PDF to the client?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13028
Just dont worry about it.

The client side closed the connection for some reason, nothing can be done on the server side to prevent this.

You could catch the Exception in your servlet method if you need to log that the transfer was incomplete.

It is sorta covered in the JavaRanch Style Guide.
subject: urgent help - Connection reset by peer: socket write error
It's not a secret anymore!