umqtt (MQTT) simple 'OSError: -1' and Mosquitto Broker - Duplicate MQTT Client Names #11790
Unanswered
DS256
asked this question in
RP2040 / Pico
Replies: 1 comment 1 reply
-
The behaviour of Mosquitto seems reasonable. A broker on the internet may have clients with dynamic IP's. If a client connects with a new IP, it makes sense to drop the original connection and to accept the new one. In any event, this does not seem to be a problem with the MicroPython client. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I encounter the following Micropython error on a previously working PICO W that publishes weather readings to a Mosquitto 2.0.11 MQTT Broker. I am using 'simple 1.3.4'
Google searches return all sorts of approaches to solve the 'OSError: -1' problem with simple, normally socket related. I was plagued by the idea nothing had change in the programming.
Running a 'mosquitto_sub' revealed sensor readings that were not associated with the PICO BME280 sensor but registered to 'weth-2'. The PICO is client 'weth-2'.
I then checked the Mosquitto log file and found the same 'weth-2' client connecting from two different IP addresses. Mosquitto was dropping one when the other connection request came in closing the socket I presume.
192.168.0.145 is the PICO and registers as 'weth-2' . 192.168.0.146 is a PI 3 B+ and is normally 'weth-1'. I had been modifying the program on 'weth-1' and inadvertently changed it's name from 'weth-1' to 'weth-2'. Both the PICO and PI 3 were running at the same time with the same client name.
Correcting the naming from 'weth-2' back to 'weth-1' stopped the 'OSError: -1' error from occurring on the PICO W.
Interestingly enough, the Python program running on the PI 3 never reported an error. I am using the 'PAHO MQTT Client' there. It was too big to use with Micropython on the PICO W so I used 'simple'
I'm posting this in case someone else has the same problem since it is not the same as the other 'OSERR: -1' issues related to sockets. Check that you are not using duplicate MQTT Client names.
Beta Was this translation helpful? Give feedback.
All reactions