Fix NATS connection for IP-addressed and path-based event receivers - #71
Merged
Conversation
The websocket handshake builds its request from the host plus Options.ProxyPath and drops the path of the server URL, so a receiver address like wss://10.2.1.39:443/nats requested / and failed with "invalid websocket connection". Pass the path as nats.ProxyPath. Also default a missing port to 443, and skip TLS hostname verification when the receiver is addressed by a bare IP, which can never match the serving cert SANs. Signed-off-by: Arnob kumar saha <arnob@appscode.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The websocket handshake in
nats.gobuilds its request URL from the host plusOptions.ProxyPathand drops the path of the server URL (ws.go#L617-L625). So a receiver address likewss://10.2.1.39:443/natsrequested/instead and failed with:NewConnectionnow normalizes the receiver address before connecting:nats.ProxyPath, so the upgrade request hits/nats443TLSConfigis set, notnats.Secure(), so a non-TLS server still connects in plain mode.Also stops the retry ticker on return; it leaked on every
NewConnectioncall.