Skip to content

Don't warn when a connection closes without sending data - #49

Merged
markmnl merged 2 commits into
mainfrom
quiet-empty-connections
Sep 25, 2026
Merged

markmnl merged 2 commits into
mainfrom
quiet-empty-connections

Conversation

@markmnl

@markmnl markmnl commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Problem

TCP health checks, load balancer probes and port scanners connect to the fmsg port, sometimes complete the TLS handshake, and then close without sending anything. Each of these logged:

WARN: reading header from, 203.0.113.7:51234: EOF

With a health check running every minute from several regions, these warnings flood the log and bury real ones.

Change

  • responseTrackingConn now also counts the bytes read from the connection.
  • When readHeader fails before any bytes arrived, and the error is io.EOF or a connection reset, handleConn logs it at INFO (INFO: <addr> closed the connection without sending data) instead of as a warning, so operators still see who connected and from where.
  • Everything else still warns exactly as before:
    • a partial or malformed header;
    • a read timeout;
    • a non-TLS client;
    • any other TLS or read error.

Tests

cmd/fmsgd/empty_conn_test.go, run against a real TLS listener:

  • A plain TCP connect-and-close doesn't warn.
  • A completed TLS handshake followed by a close doesn't warn.
  • A connection that sends only the version byte and then closes still warns.
  • A table test for closedWithoutData: EOF or reset before any data counts as a silent close. EOF after some data, a timeout, or other errors don't.

With the check disabled, the two probe tests fail, so the tests do catch the old behaviour.

go vet ./... and go test ./... pass.

🤖 Generated with Claude Code

markmnl and others added 2 commits September 25, 2026 11:52
TCP health checks, load balancer probes and port scanners connect to the
fmsg port (sometimes completing the TLS handshake) and close without
sending anything. Each one logged "WARN: reading header from, <ip>: EOF",
which floods the log and buries real warnings.

handleConn now counts the bytes it reads, and when the header read fails
with EOF or a connection reset before any bytes arrived, it closes the
connection without a warning. The existing INFO line still records the
connection. A partial or malformed header, a timeout, or any other error
still warns as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Operators still see who connected and from where, just not as a
warning.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@markmnl
markmnl merged commit 71a09e0 into main Sep 25, 2026
2 checks passed
@markmnl
markmnl deleted the quiet-empty-connections branch September 25, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant