eclipse / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
8.88k stars 2.36k forks source link

clients with packet identifier set to zero being rejected #2681

Open davoau opened 1 year ago

davoau commented 1 year ago

I have recently upgraded from mosquitto version 1.5.7 to 2.0.11 - went from piOS buster to bullseye. I stopped getting mqtt messages from my SolaX inverter, with the mosquitto log file showing the following entries.

1667545518:` New connection from 10.0.1.8:46313 on port 2901.
1667545520: New client connected from 10.0.1.8:46313 as SWHXXXXXX (p2, c1, k600, u'SWHXXXXXX').
1667545523: Client SWHXXXXXX disconnected due to protocol error.
1667545749: New connection from 10.0.1.8:41214 on port 2901.
1667545750: New client connected from 10.0.1.8:41214 as SWHXXXXXX (p2, c1, k600, u'SWHXXXXXX').
1667545753: Client SWHXXXXXX disconnected due to protocol error.
1667546052: New connection from 10.0.1.8:29870 on port 2901.
1667546052: New client connected from 10.0.1.8:29870 as SWHXXXXXX (p2, c1, k600, u'SWHXXXXXX').
1667546055: Client SWHXXXXXX disconnected due to protocol error.
1667546277: New connection from 10.0.1.8:37995 on port 2901.
1667546277: New client connected from 10.0.1.8:37995 as SWHXXXXXX (p2, c1, k600, u'SWHXXXXXX').
1667546281: Client SWHXXXXXX disconnected due to protocol error.

After spending a few days trying to work out what the issue is and alot of google searching I have found that it is due to the Solax inverter setting the packet identifier to zero.

I have managed to get it to work with by commenting out the following in handle_publish.c and compiling my own binary.

        /* if(mid == 0){
            db__msg_store_free(msg);
            return MOSQ_ERR_PROTOCOL;
        } */

I am wondering if it is possible to put an option in mosquitto.conf to not reject packet identifiers set to zero, as my invert wifi dongle with never get a firmware update and there must be others out there that are using mqtt clients with this issue.

Thanks David

nzmichaelh commented 1 year ago

Hi David. FWIW, I had the same problem and locally patched Mosquitto. See https://juju.nz/michaelh/post/2021/solax/

davoau commented 1 year ago

Hi, What options/build dependences did you use.. I have just done a new install of piOS and home assistant over he weekend (I had forgot all about this problems until I got you comment) and complied it. The new mosquitto binary is 1.8MB against the originals 297k on the piOS 2023.03 - new build is version 2.0.15, original is 2.0.12. It is working fine but just curious to know why the binary file is so big now, and if I can get it smaller. Thanks David