LabVIEW-Open-Source / MQTT-Client

A LabVIEW-based client for MQTT
Other
27 stars 5 forks source link

Connection issue with Mosquitto 2.0.14 #11

Closed bruniii closed 2 years ago

bruniii commented 2 years ago

Hello,

I have recently installed on multiple Windows PC the 2.0.14 version of the Mosquitto broker. Now even the minimal client example distributed with the MQTT-client library cannot connect to the broker; up to 2.0.11 everything was working fine. Specifically, I'm getting Error 66 out of the "Connect to Server.vi".

Attached the block diagram; as you can see, the vi is the basic example with a TCP connection.

mqtt_issue

I have looked at the changelog (https://mosquitto.org/ChangeLog.txt) but I'm not an expert, just a user of your nice collection of MQTT library.

Could you please check if you are able to reproduce the same error?

Thank you, Marco.

francois-normandin commented 2 years ago

@bruniii Please check if Mosquitto 2.0 runs version 3.1 or 5.0 of the MQTT protocol.

The LV-MQTT library currently only supports 3.1

auge commented 2 years ago

I had similar issues: @bruniii pls check the mosquitto logs. mosquitto seems to not properly implement keep-alive:0 (which is the default for the LV MQTT Client): https://github.com/eclipse/mosquitto/issues/2462

I simply set a keep-alive other than 0 (60 in my case) which worked nicely.

regards

francois-normandin commented 2 years ago

My assumption is that there is something not supported which resolves to a protocol violation. Error 66 in LabVIEW means that the connection is closed by peer (server in this case). If there are no replies at all, it means that the bytes sent are not accepted as valid format. If it were a refusal because of credentials, you would get a CONNACK packet with a reason for refusal, then a disconnection. The fact that it disconnects right away, without a CONNACK packet, seems to indicate a protocol violation.

I would have expected Mosquitto to support 3.1.1, but I read on their release notes that they reject if keep-alive is not formatted.

francois-normandin commented 2 years ago

thanks for confirming @auge !!!

bruniii commented 2 years ago

@auge and @francois-normandin thank you! I can confirm that with a "keep alive" value greater than zero everything is working fine!

francois-normandin commented 2 years ago

For the record, the MQTT Client 4.0.0 upgrade available on VIPM now sets Keep-Alive at 60s by default.

(Be sure to upgrade the whole MQTT Connection stack to 4.0.x at the same time. The stack is unchanged except for inheritance to a more generic "Connection" class. Unless you used the MQTT Connection public methods, no break in code is expected)

bruniii commented 2 years ago

I found out that it's still possible to use "keep alive" equal to 0 ( = forever) if the line max keepalive 0 is added to the mosquitto.conf in C:\Program Files\mosquitto\ (remember to restart the service).