Open HaKAtWork opened 2 weeks ago
I'd argue that this is fully intentional and working as designed - it's a v5 client after all!? there are quite some changes between the two protocol versions, supporting both via the same API is probably quite cumbersome and confusing (if you cannot use certain functions depending on which broker you'd be connected to, etc.)
I have not looked at the code, but I agree with @ssams, for whichever language/library you use. If you request an MQTT v5 connection, it should definitely fail if that is not supported by the server. The v5 protocol has quite a number of new features, and if the client needs to use those features, it should be told explicitly that it can not.
If the client can make use of v3, it can always retry the connection using the v3 protocol. For that matter, if it is not going to make use of v5, and is likely to connect to an old broker, it should probably just request a v3 connection from the begining.
I would like to be able to connect to different brokers with one (Java) client. These different brokers support different versions of Mqtt. To be able to support both V3 and V5, I have to integrate both libs in the client. I would like to be able to use V3 with one lib (without using the new features).
Test with (very old) mosquitto version 1.5.5 (MQTTv5 client) Debug-Messages from mosquitto: New connection from .... Invalid protocol version 5 in CONNECT from .... Sending CONNACK to ... Socket error on client, disconnecting.
Test with (very old) mosquitto version 1.5.5 (MQTTv3 client) no error Debug-Messages from mosquitto: New connection from... New client connected from ...
There is no way to set the MQTT version as in the MQTTv3 client (setMqttVersion), because the method is missing. Is no automatic fallback to V3.1.1 implemented?