Recently I faced the issue while working on some legacy code. After googling I found that the issue is everywhere but without any concrete resolution. I worked on various parts of the exception message and analyzed below.
Analysis:
SSLException
: exception happened with the SSL (Secure Socket Layer), which is implemented in javax.net.ssl
package of the JDK (openJDK/oracleJDK/AndroidSDK
)Read error ssl=# I/O error during system call
: Error occured while reading from the Secure socket. It happened while using the native system libraries/driver. Please note that all the platforms solaris, Windows etc. have their own socket libraries which is used by the SSL. Windows uses WINSOCK library.Connection reset by peer
: This message is reported by the system library (Solaris reports ECONNRESET
, Windows reports WSAECONNRESET
), that the socket used in the data transfer is no longer usable because an existing connection was forcibly closed by the remote host. One needs to create a new secure path between the host and clientReason:
Understanding the issue, I try finding the reason behind the connection reset and I came up with below reasons:
Network dropped connection on reset(On Windows(WSAENETRESET))
and Subsequent operations fail withConnection reset by peer(On Windows(WSAECONNRESET))
.Resolution:
Connection reset by peer
.Connection reset by peer
.Connection reset by peer
. Here are the terms suggested to set on various forums to resolve the issue
ConnectionTimeout:
Used only at the time out making the connection. If host takes time to connection higher value of this makes the client wait for the connection.SoTimeout
: Socket timeout-It says the maximum time within which the a data packet is received to consider the connection as active.If no data received within the given time, the connection is assumed as stalled/broken.Linger
: Upto what time the socket should not be closed when data is queued to be sent and the close socket function is called on the socket.TcpNoDelay
: Do you want to disable the buffer that holds and accumulates the TCP packets and send them once a threshold is reached? Setting this to true will skip the TCP buffering so that every request is sent immediately. Slowdowns in the network may be caused by an increase in network traffic due to smaller and more frequent packet transmission.So none of the above parameter helps keeping the network alive and thus ineffective.
I found one setting that may help resolving the issue which is this functions
setKeepAlive(true)
setSoKeepalive(HttpParams params, enableKeepalive="true")
How did I resolve my issue?
HttpConnectionParams.setSoKeepAlive(params, true)
SSLException
and check for the exception message for Connection reset by peer
I hope the details help. Happy Coding...