ERROR smtpserver: Socket to hostname (x.x.x.x) closed remotely. java.net.SocketException: Connection reset

Haproxy smtpchk is flooding errors in smtpservers.log. The option “option smtpchk” in the (haproxy.cfg) SMTP backend is causing the below error at every check.

ERROR smtpserver: Socket to hostname (x.x.x.x) closed remotely.
java.net.SocketException: Connection reset
at java.base/java.net.SocketInputStream.read(Unknown Source)
at java.base/java.net.SocketInputStream.read(Unknown Source)
at java.base/java.io.BufferedInputStream.fill(Unknown Source)
at java.base/java.io.BufferedInputStream.read(Unknown Source)
at org.apache.james.util.CRLFTerminatedReader.read(CRLFTerminatedReader.java:153)
at org.apache.james.util.CRLFTerminatedReader.readLine(CRLFTerminatedReader.java:113)
at org.apache.james.smtpserver.SMTPHandler.readCommandLine(SMTPHandler.java:751)
at org.apache.james.smtpserver.SMTPHandler.handleConnection(SMTPHandler.java:372)
at org.apache.james.util.connection.ServerConnection$ClientConnectionRunner.run(ServerConnection.java:432)
at org.apache.excalibur.thread.impl.ExecutableRunnable.execute(ExecutableRunnable.java:55)
at org.apache.excalibur.thread.impl.WorkerThread.run(WorkerThread.java:116)

After removing the smtpchk then the error disappears. Any ideas? I have even tried setting the correct domain for SMTP in the option smtpchk on haproxy.config file but its not working.

@lukastribus Any help would be appreciated?

I’m not entirely sure but one of my customers was having the same problem so I suggested they can check the ports and they found it was due to the port.

A fix has been committed and the next release will contain it: