Skip to content

Commit

Permalink
Handle edge case where socket is None
Browse files Browse the repository at this point in the history
* The following exception happens randomly on startup:

```
Exception has occurred: AttributeError
'NoneType' object has no attribute 'recv'
File "paho/mqtt/client.py", line 640, in _sock_recv
```

* The root cause is unknown, but this allows the library to reconnect
  gracefully.

Signed-off-by: Robert DeRose <RobertDeRose@gmail.com>
  • Loading branch information
RobertDeRose committed Nov 17, 2022
1 parent 9782ab8 commit 169edce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/paho/mqtt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,7 @@ def _packet_read(self):
data = self._sock_recv(self._in_packet['to_process'])
except BlockingIOError:
return MQTT_ERR_AGAIN
except ConnectionError as err:
except (ConnectionError, AttributeError) as err:
self._easy_log(
MQTT_LOG_ERR, 'failed to receive on socket: %s', err)
return MQTT_ERR_CONN_LOST
Expand Down

0 comments on commit 169edce

Please sign in to comment.