Skip to content

Log TCP acceptor (Ranch) timeout and TLS [handshake-related] errors #13979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 30, 2025

Conversation

LoisSotoLopez
Copy link
Contributor

Proposed Changes

This PR addresses #11171

The proposed changes catch the exit signal emitted by ranch:handshake in rabbit_networking:handshake and log an error message in case the reason for shutting down the connection is other than closed.

The reason for not logging closed shutdown exit exceptions has been added as a context comment in the source.

Types of Changes

  • Bug fix (non-breaking change which fixes issue #NNNN)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause an observable behavior change in existing systems)
  • Documentation improvements (corrections, new content, etc)
  • Cosmetic change (whitespace, formatting, etc)
  • Build system and/or CI

Checklist

Put an x in the boxes that apply.
You can also fill these out after creating the PR.
If you're unsure about any of them, don't hesitate to ask on the mailing list.
We're here to help!
This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING.md document
  • I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq)
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally with my changes
  • If relevant, I have added necessary documentation to https://github.com/rabbitmq/rabbitmq-website
  • If relevant, I have added this change to the first version(s) in release-notes that I expect to introduce it

Further Comments

Protocol = ranch_ref_to_protocol(Ref),
rabbit_log:error("~p error during handshake for protocol ~p and peer ~ts",
[Reason, Protocol, PeerAddress]),
exit({shutdown, {Reason, PeerInfo}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better in both catch cases to call erlang:raise/3 so that we don't lose the stacktrace which may be propagated to other processes.

@@ -547,7 +562,7 @@ failed_to_recv_proxy_header(Ref, Error) ->
end,
rabbit_log:debug(Msg, [Error]),
% The following call will clean up resources then exit
_ = ranch:handshake(Ref),
_ = catch ranch:handshake(Ref),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way of doing catch is being deprecated by Erlang/OTP team so it would be better as a try catch.

try_ranch_handshake(Ref) ->
try ranch:handshake(Ref) of
{ok, Sock} ->
Sock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no reason no to return {ok, Sock}. You could also use the name ranch_handshake as the "try" doesn't tell us much.

@LoisSotoLopez LoisSotoLopez force-pushed the tls-handshake-logging branch from bc8023b to 223ef6d Compare May 30, 2025 07:48
@LoisSotoLopez LoisSotoLopez force-pushed the tls-handshake-logging branch from 223ef6d to 3a5dc94 Compare May 30, 2025 07:51
@LoisSotoLopez LoisSotoLopez requested a review from lhoguin May 30, 2025 08:32
@michaelklishin michaelklishin added this to the 4.2.0 milestone May 30, 2025
@michaelklishin michaelklishin changed the title Log ranch timeout and tls errors Log TCP acceptor (Ranch) timeout and TLS [handshake-related] errors May 30, 2025
@michaelklishin
Copy link
Collaborator

The failures are not specific to this PR.

@michaelklishin michaelklishin merged commit 795e66c into rabbitmq:main May 30, 2025
822 of 837 checks passed
michaelklishin added a commit that referenced this pull request May 30, 2025
Log TCP acceptor (Ranch) timeout and TLS [handshake-related] errors (backport #13979)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants