mailslurper icon indicating copy to clipboard operation
mailslurper copied to clipboard

Error when sending a large number of mails

Open adharshgec opened this issue 5 years ago • 2 comments

So I'm doing a performance test of an application that sends mails. The application and mailslurper is setup using docker-compose and I'm using the default custom-config.json file. When the number of mails reaches the 13000th mark, mailslurper is throwing this error:

level=error msg="Error adding connection '172.21.0.7:42662' to connection manager" 
error="Connection on '172.21.0.7:42662' already exists" who="SMTP Listener"

The rest of the mails are not being processed.

adharshgec avatar Apr 02 '20 05:04 adharshgec

Same problem here. I suspected the ConnectionManager not cleaning up the ConnectionPool.

Adding an extra log statement confirmed this:

diff --git a/pkg/mailslurper/ConnectionManager.go b/pkg/mailslurper/ConnectionManager.go
index b29066d..39b0bc6 100644
--- a/pkg/mailslurper/ConnectionManager.go
+++ b/pkg/mailslurper/ConnectionManager.go
@@ -117,7 +117,7 @@ use this to track a client connection and its worker
 func (m *ConnectionManager) New(connection net.Conn) error {
 	var err error
 	var worker *SMTPWorker
-
+	m.logger.Infof("Number of connections %d", len(m.connectionPool))
 	if m.connectionExistsInPool(connection) {
 		return ConnectionExists(connection.RemoteAddr().String())
 	}

When i tried to clean it up however, it calls close multiple times, resulting in the following error:

INFO[0003] Closing connection 127.0.0.1:51259            who="Connection Manager"
INFO[0003] in go <- closeChannel Closed                  who="Connection Manager"
INFO[0003] Connection closed                             connection="127.0.0.1:51259" who="Connection Manager"
INFO[0003] in go <- closeChannel Closed                  who="Connection Manager"
ERRO[0003] Error closing connection                      error="Connection '127.0.0.1:51259' is not in the connection manager pool" who="Connection Manager"
INFO[0003] Connection closed                             connection="127.0.0.1:51259" who="Connection Manager"

hdevalke avatar May 27 '21 19:05 hdevalke

I can confirm this is still a problem on the latest OSX binary.

stevenmc avatar May 11 '22 14:05 stevenmc