Skip to content

Commit

Permalink
Merge pull request #624 from ChIoT-Tech/master
Browse files Browse the repository at this point in the history
Allow MQTT username/password in URL when connecting via Websockets
  • Loading branch information
MattBrittan committed Dec 22, 2022
2 parents d9dea69 + 3a8066f commit 4b066a0
Showing 1 changed file with 6 additions and 2 deletions.
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)
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

0 comments on commit 4b066a0

Please sign in to comment.