Skip to content
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

Do DNS resolution before connection attempt #893

Merged
merged 4 commits into from
Jul 7, 2020
Merged

Do DNS resolution before connection attempt #893

merged 4 commits into from
Jul 7, 2020

Conversation

JeremyMahieu
Copy link
Contributor

@JeremyMahieu JeremyMahieu commented Jul 6, 2020

Proposed Changes

When starting an application (with all exceptions on) rabbitmq always gives a couple of exceptions because it first tries to connect to IPv6 (and fails) but then succeeds to connect to IPv4. RabbitMQ is using exceptions as normal control flow. This is annoying. It makes the user wonder what he did wrong, and has to wressle through the startup of his program clicking away all the exceptions. Usually one will disable the recurring exceptions at the risk of missing it when it's relevant.

As asked in https://groups.google.com/g/rabbitmq-users/c/sHeiZMBwfWU
Also see https://stackoverflow.com/a/86395708/1560347 .

Types of Changes

What types of changes does your code introduce to this project?
Put an x in the boxes that apply

  • Bug fix (non-breaking change which fixes issue)
  • 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)

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)
  • All tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in related repositories

Further Comments

This pull request probably need some work. This is more of a proof of concept, please let me know what you think.

It's probably a big no-no to change the api, however it's impossible to pass an endpoint without doing the DNS resolution internally.

Copy link
Member

@michaelklishin michaelklishin left a comment

Choose a reason for hiding this comment

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

API approval tests also need updating. Run them with

dotnet test -f netcoreapp3.1 projects/Unit --filter "FullyQualifiedName~RabbitMQ.Client.Unit.APIApproval"

To see the diff:

diff projects/Unit/APIApproval.Approve.received.txt projects/Unit/APIApproval.Approve.verified.txt

or similar.

@stebet
Copy link
Contributor

stebet commented Jul 7, 2020

Just one thing I was wondering, is there a reason the RabbitMQ client doesn't just let the operating system decide if it should connect via IPv4 or IPv6 when it's given a hostname?

@JeremyMahieu
Copy link
Contributor Author

Well most systems are dual stack now so the OS has the capabilities to connect using IPv6 and IPv4. However when someone sets up a server they will still only configure IPv4 entries in the DNS. The OS has no way of knowing what DNS entries there will be until it resolves the hostname. And even then the server can be up on IPv4 and not on IPv6 or vice versa, which the OS can also not know.

@michaelklishin
Copy link
Member

@stebet unfortunately, the client cannot know what address family should be used or preferred. Local OS cannot know that either since target nodes can be configured to only listen for connections that use IPv6. Trying both families is the best default behavior.

@michaelklishin michaelklishin merged commit e84d339 into rabbitmq:master Jul 7, 2020
@michaelklishin michaelklishin added this to the 7.0.0 milestone Jul 7, 2020
@michaelklishin
Copy link
Member

This changes an interface so can only go into 7.0.

@lukebakken lukebakken modified the milestones: 8.0.0, 7.0.0 Mar 8, 2022
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.

4 participants