MQTT: OSError: -1 from line 160, in wait_msg
semireg last edited by semireg
I've searched the forums and this is the closest post to what I'm experiencing:
This is on a new WiPy 3.0 with default MQTT library. This also happens using the other version from micropython-lib (https://github.com/micropython/micropython-lib/blob/master/umqtt.simple/umqtt/simple.py).
I've tried setting timeout to different values, no luck. This code was working fine on an ESP8266. Thoughts?
(sysname='WiPy', nodename='WiPy', release='1.11.0.b1', version='3032601 on 2017-12-30', machine='WiPy with ESP32')
Here's the relevant code:
# Wait for a single incoming MQTT message and process it. # Subscribed messages are delivered to a callback previously # set by .set_callback() method. Other (internal) MQTT # messages processed internally. def wait_msg(self): res = self.sock.read(1) self.sock.setblocking(True) if res is None: return None if res == b"": raise OSError(-1) # <-- LINE 160 if res == b"\xd0": # PINGRESP sz = self.sock.read(1) assert sz == 0 return None
My guess is the socket implementation has a bug - it should return
Noneinstead of a zero length bytes object. If that's the case, a quick fix would be to make the check less strict:
if res is None or res == b"": return None
This seems to work OK... What are the implications for relaxing this check?
daniel last edited by
@semireg We'll have a look to see if there's a bug in the socket implementation.