Skip to content
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

Fix MQTT connections being refused when using empty username #1257

Closed
mpvader opened this issue Apr 20, 2024 · 0 comments
Closed

Fix MQTT connections being refused when using empty username #1257

mpvader opened this issue Apr 20, 2024 · 0 comments

Comments

@mpvader
Copy link
Contributor

mpvader commented Apr 20, 2024

NOTE: I wrote this issue mainly to have the details available when someone asks again in the future - problem is solved already; per Venus OS v3.31

The story:

Per Venus OS ... we switched from Mosquitto to FlashMQ. And that resulted, for some MQTT clients, in a regression:

There is a difference between how Mosquitto and FlashMQ treat anonymous logins on MQTT. Mosquitto treated the specifications a bit loosely, and accepted an empty username, instead of only no username. FlashMQ is more strict, and if during login the client says that there is a username, it also expects one. And if there is none, it refuses to connect.

On some clients and implementations that works fine; but - as clear now - there are also implementations on which that gives a problem. What you see then is that the software you're using is unable to connect. If you'd look in the logs on the GX device, you'd see this:

[ERROR] Unspecified or non-MQTT protocol error: Username flagged as present, but it's 0 bytes.. Removing client.
To work around this, configure a username and password in the MQTT software you are using. Then FlashMQ will accept the connection, even though there is no username or password required.

Note that that workaround does not require you to login to the GX command line and make changes there.

Per Venus OS v3.31, that was fixed, by updating flashmq + enabling the new zero_byte_username_is_anonymous option.

Which clients were affected is not totally clear, but names that were mentioned on Community are the openEVSE charger and edomi/knx. The often used MQTT Explorer package is not affected.

Here is how to test / reproduce it, all using the MQTT v5 protocol. With v3.11 protocol its the same.:

## No user name against Venus OS v3.30 - connects OK

matthijs@mva-ubuntu2204:~$ mosquitto_sub -d -t '#' -h 192.168.178.221 -V 5
(...)
{"value":"c0847dc9a93d"}


## Empty user name against Venus OS v3.30 - connection FAILS:

$ mosquitto_sub -d -t '#' -h 192.168.178.221 -u '' -P '' -V 5
Client (null) sending CONNECT
Client (null) received CONNACK (129)
Connection error: Malformed Packet
Client (null) sending DISCONNECT
^C

## No user name against Venus OS v3.31 - still connects OK

$ mosquitto_sub -d -t '#' -h 192.168.178.221 -V 5
(...)
{"value":"c0847dc9a93d"}
^C

## Empty user name againast Venus OS v3.31 - connects OK - PROBLEM SOLVED:

$ mosquitto_sub -d -t '#' -h 192.168.178.221 -u '' -P '' -V 5
(...)
{"value":"c0847dc9a93d"}
^C
@mpvader mpvader closed this as completed Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant