• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

urgent help - java.net.SocketException: Connection reset by peer: socket write error

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 java.net.URL 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 = bis.read(buff, 0, buff.length))){
out.write(buff, 0, bytesRead);
}

Many a times it works properly and the pdf is rendered but sometimes I get 'java.net.SocketException: 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:
java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at weblogic.servlet.internal.ChunkUtils.writeChunkTransfer(ChunkUtils.java:247)
at weblogic.servlet.internal.ChunkUtils.writeChunks(ChunkUtils.java:223)
at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:296)
at weblogic.servlet.internal.ChunkOutput.checkForFlush(ChunkOutput.java:371)
at weblogic.servlet.internal.ChunkOutput.write(ChunkOutput.java:241)
at weblogic.servlet.internal.ChunkOutputWrapper.write(ChunkOutputWrapper.java:113)
at weblogic.servlet.internal.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:184)
at tavant.olympus.common.utils.ServletHelper.writeToServletOutputStream(ServletHelper.java:48)
at tavant.olympus.base.GenericRetrievalServlet.sendRequestAndPrintTheResponse(GenericRetrievalServlet.java:90)
at

tavant.olympus.client.aereports.AEStaticReportsRetrievalServlet.serviceRequest(AEStaticReportsRetrievalServlet.java:34)
at tavant.olympus.base.GenericRetrievalServlet.doPost(GenericRetrievalServlet.java:57)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)

Any kinna help will be highly appreciated !!
Thanx in advance.
Mudit
 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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.

Vijay
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am also facing same issue, please give me the solution for this issue.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The same issue? So you are using WebLogic v8.1 and are streaming a PDF to the client?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Bill
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic