You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, when looking at the websocket example, the host argument of MqttOptions::new(...) is not the hostname, but the full websocket URL:
// port parameter is ignored when scheme is websocketletmut mqttoptions = MqttOptions::new("clientId-aSziq39Bp3","ws://broker.mqttdashboard.com:8000/mqtt",8000,);
mqttoptions.set_transport(Transport::Ws);
If using the parse_url for ws://broker.mqttdashboard.com:8000/mqtt?client_id=clientId-aSziq39Bp3 then this would result in host being set to broker.mqttdashboard.com, not ws://broker.mqttdashboard.com:8000/mqtt.
The result is the following error being returned by the eventloop:
Invalid Url: Couldn't parse host from url.
The text was updated successfully, but these errors were encountered:
Hey, thanks for reporting, the way we handle ws / wss differently from tcp is the root of this.
I think it is handled that way because when using websockets, address can have path like /mqtt, which isn't case with normal tcp. So when we treat host as full URL, this can be done:
this PR would allow users to provide partial / full urls for both tcp & ws! it is still draft because I'm waiting for feedback on design, like shall we return error if we fail to parse, or shall we panic. ( more details in PR desc )
I believe these two options are equal:
The
url
crate is used to parse the transport, hostname and port. Then theclient_id
is retrieved by reading the URL parameters, etc...https://github.com/bytebeamio/rumqtt/blob/main/rumqttc/src/v5/mod.rs#L581
However, when looking at the websocket example, the
host
argument ofMqttOptions::new(...)
is not the hostname, but the full websocket URL:https://github.com/bytebeamio/rumqtt/blob/main/rumqttc/examples/websocket.rs#L10
If using the
parse_url
forws://broker.mqttdashboard.com:8000/mqtt?client_id=clientId-aSziq39Bp3
then this would result inhost
being set tobroker.mqttdashboard.com
, notws://broker.mqttdashboard.com:8000/mqtt
.The result is the following error being returned by the eventloop:
Invalid Url: Couldn't parse host from url.
The text was updated successfully, but these errors were encountered: