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
Allow MQTT username/password in URL when connecting via Websockets #624
Conversation
…ername/password to be specified in URL) Closes eclipse#623
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) |
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.
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
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.
ping @MattBrittan (apologies if inappropriate, but doing this since I'm responding to a closed PR)
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.
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.
…worked for the first, but not subsequent, connections) Closes eclipse#623
This MR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/eclipse/paho.mqtt.golang](https://github.com/eclipse/paho.mqtt.golang) | require | patch | `v1.4.1` -> `v1.4.3` | --- ### Release Notes <details> <summary>eclipse/paho.mqtt.golang (github.com/eclipse/paho.mqtt.golang)</summary> ### [`v1.4.3`](https://github.com/eclipse/paho.mqtt.golang/releases/tag/v1.4.3) [Compare Source](eclipse/paho.mqtt.golang@v1.4.2...v1.4.3) Release 1.4.3 is a relatively small release to bring in changes made in the eight months since 1.4.2. Thanks to everyone who submitted issues and contributed code (list of the main merged pull requests below): #### What's Changed - Avoid Panic when keepalive is 1 by [@​tomatod](https://github.com/tomatod) in [#​622](eclipse/paho.mqtt.golang#622) - Allow MQTT username/password in websocket URI [@​MattBrittan](https://github.com/MattBrittan) in [#​624](eclipse/paho.mqtt.golang#624) - Add backoff when reconnecting following immediate connection loss [@​tomatod](https://github.com/tomatod) in [#​625](eclipse/paho.mqtt.golang#625) - Update dependencies (github.com/gorilla/websocket@v1.5.0, golang.org/x/net, golang.org/x/sync) and specify `go 1.18` in `go.mod`. **Full Changelog**: eclipse/paho.mqtt.golang@v1.4.2...v1.4.3 ### [`v1.4.2`](https://github.com/eclipse/paho.mqtt.golang/releases/tag/v1.4.2) [Compare Source](eclipse/paho.mqtt.golang@v1.4.1...v1.4.2) Release 1.4.2 is relatively small and is mostly focused on tidying up the way the library manages the connection status. Previously `sync/ atomic` was used to read/update the status but this led to a range of potential deadlocks, and workarounds to avoid these, which made the code difficult to follow. The new [connectionStatus](https://github.com/eclipse/paho.mqtt.golang/blob/master/status.go#L113) separates status handling from `client` and should simplify further development whilst resolving potential race conditions. It is my hope that users will not notice any change ([@​master](https://github.com/master) was updated on 10th August and the updated code has been running in production at a few sites since then without issue). A further change is that it is now possible to disable auto acknowledgment so that received messages can be manually acknowledged (or, more to the point, not acknowledged!). Thanks to everyone who submitted issues and contributed code (list of the main merged pull requests below): #### What's Changed - Tidy up use of mutex in `messageIds` by [@​MattBrittan](https://github.com/MattBrittan) in [#​602](eclipse/paho.mqtt.golang#602) - Resolve situation where broker accepted connection but did not respond to CONNECT packet in a timely manner (should be very unusual but was reported in [#​597](eclipse/paho.mqtt.golang#597)). [@​MattBrittan](https://github.com/MattBrittan) in [#​603](eclipse/paho.mqtt.golang#603) - Resolve race condition in test by [@​MattBrittan](https://github.com/MattBrittan) in [#​606](eclipse/paho.mqtt.golang#606) - Re-architect status handling by [@​MattBrittan](https://github.com/MattBrittan) in [#​607](eclipse/paho.mqtt.golang#607) - Enable manual ACK by [@​shivamkm07](https://github.com/shivamkm07) in [#​578](eclipse/paho.mqtt.golang#578) #### New Contributors - [@​shivamkm07](https://github.com/shivamkm07) made their first contribution in [#​578](eclipse/paho.mqtt.golang#578) **Full Changelog**: eclipse/paho.mqtt.golang@v1.4.1...v1.4.2 </details> --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yODYuMSIsInVwZGF0ZWRJblZlciI6IjM3LjI4Ni4xIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=--> See merge request alpine/infra/build-server-status!8
Clear URL User before creating websocket connection (allowing MQTT username/password to be specified in URL). If u.User is not nil then the Gorilla Websocket library will reject the connection attempt.
Closes #623