Thursday, April 26, 2018

How to Debug " Connection reset by peer"?

There are many reasons that WebLogic server may throw below exception: Connection reset by peer
In this article, we will use one specific case for discussion.

Stack Trace

####<Apr 26, 2018, 8:42:37,381 AM UTC> <Error> <HTTP> <myserver> <CloudConsoleServer_MyServices> <[ACTIVE] ExecuteThread: '23' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <XaUWE0Co100000000> <1524732157381> <[severity-value: 8] [rid: 0:1:2] [partition-id: 0] [partition-name: DOMAIN] > <BEA-101019> <[ServletContext@15863685[app:cp-myservices.ear module:mycloud path:null spec-version:3.1 version:_18.]] Servlet failed with an IOException. Connection reset by peer
        at Method)
        at weblogic.socket.NIOOutputStream$SingleBufferWrite.writeTo(
        at weblogic.socket.NIOOutputStream$BlockingWriter.flush(
        at weblogic.socket.NIOOutputStream$BlockingWriter.write(
        at weblogic.socket.NIOOutputStream.write(
        at weblogic.servlet.internal.ChunkOutput.writeChunkTransfer(
        at weblogic.servlet.internal.ChunkOutput.writeChunks(
        at weblogic.servlet.internal.ChunkOutput.flush(
        at weblogic.servlet.internal.ChunkOutput$3.checkForFlush(
        at weblogic.servlet.internal.ChunkOutput.write(
        at weblogic.servlet.internal.ChunkOutputWrapper.write(
        at weblogic.servlet.internal.ServletOutputStreamImpl.write(
        at oracle.adfinternal.view.faces.caching.filter.ResponseOutputStream.writeContentTo(
        at oracle.adfinternal.view.faces.caching.filter.AdfFacesCachingResponse._flushContent(
        at oracle.adfinternal.view.faces.caching.filter.AdfFacesCachingResponse.flush(

How to Debug

In this case, our server is connected to many applications in other servers. So, the peer-in-suspect could be from either a browser or an application running in our infrastructure.

Given the stack trace, the first thing to check is find some clues from it.  For example, in this case, we saw:


which means that WebLogic server is 
Writing the servlet response back to the client when the IOException was thrown

If this client were a browser, what happened could be:
The browser has shutdown the connection — either the browser crashed, or the browser shut the connection explicitly because the user closed that page or cancelled navigation on that page.

If this client were an application (i.e., a selenium or other testing tools), what happened could be:
Timeouts in those tools for how long they will wait for the response.
Maybe their logs would show you that they had closed the socket after some time.

HTTP Keep-Alive

In [1], the author surmized that it could be:
 " Very likely an issue with HTTP keepalive (persistent connections)."
However, this is not our case because:
Keep-alive is to make sure the socket stays open between requests. Our case is in the middle of a request, so there is no keepalive in use at that time. But conceptually it is sort of the same thing: if the client (i.e., browser) decides that the response isn't coming, it closes the socket.

If You Find Out Who's the Peer

Let assume the client is another Linux application, here are possible debugging steps:
The only thing to check at the system level is that if the machine was up the entire time — you can check its uptime, and look at dmesg for messages about the link going up or down. Otherwise, maybe the application logs will tell you if the process restarted/crashed, which is the more likely cause. 

Could tcpdump help in this case?  Probably not  because
There will probably be too much data from a tcpdump unless you know how to filter what you are looking for. 


  1. Possible Causes for "Connection reset by peer" when using NIOReferences

No comments: