mqtt_client icon indicating copy to clipboard operation
mqtt_client copied to clipboard

Fallback to websockets

Open Niek opened this issue 6 years ago • 3 comments

It would be great if it'd be possible to fall back to WS/WSS in case that the MQTT connection is not working/blocked.

Maybe a constructor that allows to pass in a list of servers that are tried in waterfall order?

Niek avatar Feb 01 '19 15:02 Niek

OK, your use case here is possible, so do you mean you want a client that given a list of connections(assume all the same for now i.e. ws/wss) it tries the first one, if it fails it tries the second and so on, when one connects that's the on you use, until some time in the future it fails, then you try the next and so on, or when the first connection succeeds that's the one you want, if it fails it fails as it does now.

Either way this won't be in the client as such, I'm introducing some management classes to perform stuff like this and topic filtering etc. This allows users to chose what they want to use without bloating the client itself, some users may want to do all their own management.

shamblett avatar Feb 03 '19 08:02 shamblett

Correct, the use case here would be that quite some corporate networks are blocking outgoing MQTT connections. So a connection to a broker with a fallback to the same broker over WSS (and maybe finally WS) would be ideal in many situations. If you think it's outside of the library scope, we'll write our own logic around it - but I thought it would be a nice addition.

Niek avatar Feb 04 '19 10:02 Niek

Its in library scope, sorry if I wasn't clear, but not in the client scope, as in a constructor on MqttClient class, it would be say in some management class say MqttClientMonitor class or something that will use the MqttClient so it will be in the library.

If you wish to have a go at this feel free, pull requests gladly accepted, if your willing to wait I will do this but it may be a couple of weeks.

shamblett avatar Feb 04 '19 12:02 shamblett