Closed wneessen closed 1 month ago
Interesting, this had me scratching my head for a while, staring at the code. I could reproduce this with the openssl command. But it turns out that the QUIT we're writing doesn't actually make it to mox: openssl s_client
interprets some input as commands for itself. Any line starting with Q closes the connection, client-side! Also see https://docs.openssl.org/3.4/man1/openssl-s_client/#connected-commands-basic. There are a few more.
If you add -nocommands on the command-line, you can write the QUIT-line properly, and you'll get a regular "connection closed" message.
Which monitoring system are you using? Perhaps it isn't writing a QUIT command after all? I'm using a blackboxexporter to monitor SMTP, it does write a QUIT, and causes a clean "connection closed" logging line.
Still, I would consider the "read: EOF (io error)" message as just a part of normal operation. In the past, that error message included something about "fatal", which scared some users. I think I may need to clean up the log levels at some point. But so far I've liked seeing connection start & end in info logging.
For reference, my blackboxexporter smtp "module" definitions are (likely copied from an example config):
smtp:
prober: tcp
tcp:
query_response:
- expect: "^220 ([^ ]+)(.+)$"
- send: "EHLO prober"
- expect: "^250-"
- send: "QUIT"
smtp_starttls:
prober: tcp
tcp:
query_response:
- expect: "^220 ([^ ]+)(.+)$"
- send: "EHLO prober"
- expect: "^250-STARTTLS"
- send: "STARTTLS"
- expect: "^220"
- starttls: true
- send: "EHLO prober"
- expect: "^250-AUTH"
- send: "QUIT"
I wasn't aware of the -nocommand
argument, good to know and a stupid default in my opinion. I also figured that the monitoring system just checks TCP 25 and does not issue any SMTP commands at all, which explains the connection EOFs, so that's an issue on my end. I'll close the issue since all questions are answered. Thanks agian for the quick support!
I noticed a lot of these log entries in my mox logs:
mox[3323]: l=info m="connection closed" err="read: EOF (io error)" pkg=smtpserver cid=19246e51e94 delta="241.016µs"
These seems to be caused by my monitoring system, which tries to check if the smtp server is running by connecting, issueing a "EHLO" and a "QUIT. Turns out, I can reproduce this via
openssl s_client
:Produces these logs:
I wonder why this causes an EOF. It seems to be related to TLS, since I can only reproduce it via STARTTLS or explicit TLS (465)? It also looks like the "QUIT" is not logged. This this does not happen on a non-TLS connection, though.
Is this an issue with mox or with openssl?