Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions netconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ import (
func openConnection(uri *url.URL, tlsc *tls.Config, timeout time.Duration, headers http.Header, websocketOptions *WebsocketOptions, dialer *net.Dialer) (net.Conn, error) {
switch uri.Scheme {
case "ws":
conn, err := NewWebsocket(uri.String(), nil, timeout, headers, websocketOptions)
dialURI := uri // #623 - Gorilla Websockets does not accept URL's where uri.User != nil
uri.User = nil
conn, err := NewWebsocket(dialURI.String(), nil, timeout, headers, websocketOptions)
Comment on lines +43 to +45
Copy link

Choose a reason for hiding this comment

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

Unless I'm mistaken, this code alters the original url (especially since it was passed in as a pointer to this function).

Shouldn't it be like this:

		dialURI := *uri // #623 - Gorilla Websockets does not accept URL's where uri.User != nil
		dialURI.User = nil
		conn, err := NewWebsocket(dialURI.String(), nil, timeout, headers, websocketOptions)

If so, then the same issue is on the "wss" branch below

Copy link

Choose a reason for hiding this comment

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

ping @MattBrittan (apologies if inappropriate, but doing this since I'm responding to a closed PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well spotted; this change did work (This was a quick fix, made on a customers site, that I needed to move to websockets urgently to bypass a firewall :-) ) but I can now see that it would have failed on subsequent connections (funnily enough I did have an issue with that site but put it down to websockets :-) ). I'll push a patch through shortly.

return conn, err
case "wss":
conn, err := NewWebsocket(uri.String(), tlsc, timeout, headers, websocketOptions)
dialURI := uri // #623 - Gorilla Websockets does not accept URL's where uri.User != nil
uri.User = nil
conn, err := NewWebsocket(dialURI.String(), tlsc, timeout, headers, websocketOptions)
return conn, err
case "mqtt", "tcp":
allProxy := os.Getenv("all_proxy")
Expand Down