This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 151
Fix 16550 "not authorized", TypeError, and others #324
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d652fd9
Don't try to disconnect if address never resolved to begin with
zarqman 4f27e3f
Don't append nodes to seeds until DNS resolves
zarqman 004f737
Prevent ensure_connected from returning half-setup connection on reentry
zarqman a7f9ec0
Test for a connection should include non-alive socket
zarqman 695971d
Ensure mongodb credentials are always sent upon (re)connection
zarqman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ def alive? | |
# | ||
# @since 1.0.0 | ||
def connect | ||
credentials.clear | ||
@sock = if !!options[:ssl] | ||
Socket::SSL.connect(host, port, timeout) | ||
else | ||
|
@@ -74,7 +75,6 @@ def connected? | |
# | ||
# @since 1.0.0 | ||
def disconnect | ||
credentials.clear | ||
@sock.close | ||
rescue | ||
ensure | ||
|
@@ -217,7 +217,10 @@ def read_data(socket, length) | |
# | ||
# @since 1.3.0 | ||
def with_connection | ||
connect if @sock.nil? || [email protected]? | ||
if @sock.nil? || [email protected]? | ||
connect | ||
apply_credentials(@original_credentials || {}) | ||
end | ||
yield @sock | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we clear credentials on connect now , instead of on disconnect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arthurnn If the socket disconnects (network issues, mongod failover, etc.), with_connection() can trigger a reconnect (sometimes without disconnect() being called). In this situation, credentials haven't been cleared and so they won't be resent, which causes the 16550 not authorized errors.
Resetting credentials ensures they're are always resent on reconnection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was brought up in my pull #286 which was rejected due to it causing some issues on 2.0. @zarqman hits the nail on the head on the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍