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
RUBY-986 Fallback to IPv4 if IPv6 isn't supported #660
Conversation
Thanks @agis- |
@estolfo Sure, will add them in a bit. |
@estolfo added a test case. I've also refactored the code to make it easier to follow; let me know if you still prefer the initial version instead. |
Thanks! |
Looks good, thanks so much! This is minor, but would you mind changing the test a little to match our formatting for consistency? Putting the 'allow' portion in a before block and check that address.socket returns an object would be great: describe "#socket" do
context 'when providing a DNS entry that resolves to both IPv6 and IPv4' do
let(:address) do
described_class.new('localhost:27017')
end
before do
allow(::Socket).to receive(:getaddrinfo).and_return(
[ ["AF_INET6", 0, "::1", "::1", ::Socket::AF_INET6, 1, 6],
["AF_INET", 0, "127.0.0.1", "127.0.0.1", ::Socket::AF_INET, 1, 6]]
)
end
it "attempts to use IPv6 and fallbacks to IPv4" do
expect(address.socket(0.0)).not_to be_nil
end
end
end |
Sure, updated! :) |
If you could just rebase against master so we can make sure tests pass, I can merge it. Thanks! |
Rebased. |
Prior to this change, if the provided server address resolved to IPv6 but the mongo server wasn't configured for IPv6, the client would continuously attempt to connect to the IPv6 address until the server_selection_timeout was hit and never fallback to IPv4. This fixes the behavior to try all the different protocol families in the list. Fixes https://jira.mongodb.org/browse/RUBY-986.
The travis failures are unrelated. I'll merge this now, thanks again! |
RUBY-986 Fallback to IPv4 if IPv6 isn't supported
Prior to this change, if the provided server address resolved to IPv6
but the mongo server wasn't configured for IPv6, the client would
continuously attempt to connect to the IPv6 address until the
server_selection_timeout was hit and never fallback to IPv4.
This fixes the behavior to try all the different protocol families in
the list.
Fixes https://jira.mongodb.org/browse/RUBY-986.