Skip to content

Commit

Permalink
Don't log when a client just opens and closed TCP connection
Browse files Browse the repository at this point in the history
Rudimentary health checks, or port scanner, or whatever can open a TCP
connection and then immediately close it without sending anything. This
change suppresses debug logging for such connections.

Fixes #179
  • Loading branch information
carlhoerberg committed Oct 21, 2024
1 parent f75071e commit bccca1e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/amqproxy/client.cr
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,6 @@ module AMQProxy
socket.flush

{tune_ok, Credentials.new(user, password, vhost)}
rescue ex
raise NegotiationError.new "Client negotiation failed", ex
end

ServerProperties = AMQ::Protocol::Table.new({
Expand All @@ -285,7 +283,5 @@ module AMQProxy
class ReadError < Error; end

class WriteError < Error; end

class NegotiationError < Error; end
end
end
4 changes: 3 additions & 1 deletion src/amqproxy/server.cr
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ module AMQProxy
channel_pool = @channel_pools[c.credentials]
c.read_loop(channel_pool)
end
rescue IO::EOFError
# Client closed connection before/while negotiating
rescue ex # only raise from constructor, when negotating
Log.debug(exception: ex) { "Client connection failure (#{remote_address}) #{ex.inspect}" }
Log.debug(exception: ex) { "Client negotiation failure (#{remote_address}) #{ex.inspect}" }
ensure
socket.close rescue nil
end
Expand Down

0 comments on commit bccca1e

Please sign in to comment.