You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are running Papercut as a service. Once in a while we are seeing a failed send on the smtp client side when disposing our SmtpClient instance with the error:
System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Mail.SmtpPooledStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.Net.ConnectionPool.Destroy(PooledStream pooledStream)
at System.Net.ConnectionPool.ForceCleanup()
at System.Net.ConnectionPoolManager.CleanupConnectionPool(ServicePoint servicePoint, String groupName)
The papercut log seems to indicate a connection was closed for being idle, but i'm not sure how we could have had it open for any great length of time:
Looking at the logic, I believe the comparison check for idle connections in ConnectionManager is incorrect
// Loop through the connections
foreach (int key in keys)
{
// If they have been idle for too long, disconnect them
if (DateTime.Now < _connections[key].LastActivity.AddMinutes(20))
{
Logger.Information(
"Session timeout, disconnecting {ConnectionId}",
_connections[key].Id);
_connections[key].Close();
}
}
The comparison should be DateTime.Now > _connections[key].LastActivity.AddMinutes(20), i.e. close the connection if the current time is more than 20 minutes after the last activity. I can submit a pull request later on.
The text was updated successfully, but these errors were encountered:
We are running Papercut as a service. Once in a while we are seeing a failed send on the smtp client side when disposing our SmtpClient instance with the error:
The papercut log seems to indicate a connection was closed for being idle, but i'm not sure how we could have had it open for any great length of time:
Looking at the logic, I believe the comparison check for idle connections in ConnectionManager is incorrect
The comparison should be
DateTime.Now > _connections[key].LastActivity.AddMinutes(20)
, i.e. close the connection if the current time is more than 20 minutes after the last activity. I can submit a pull request later on.The text was updated successfully, but these errors were encountered: