eclipse / paho.mqtt.python

paho.mqtt.python
Other
2.17k stars 723 forks source link

OSError have no include TimeoutError? #694

Open nanshenwei opened 1 year ago

nanshenwei commented 1 year ago

I found this error⬇️

Exception in thread Thread-1 (_thread_main):
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/paho/mqtt/client.py", line 3591, in _thread_main
    self.loop_forever(retry_first_connection=True)
  File "/opt/homebrew/lib/python3.10/site-packages/paho/mqtt/client.py", line 1756, in loop_forever
    rc = self._loop(timeout)
  File "/opt/homebrew/lib/python3.10/site-packages/paho/mqtt/client.py", line 1164, in _loop
    rc = self.loop_read()
  File "/opt/homebrew/lib/python3.10/site-packages/paho/mqtt/client.py", line 1556, in loop_read
    rc = self._packet_read()
  File "/opt/homebrew/lib/python3.10/site-packages/paho/mqtt/client.py", line 2370, in _packet_read
    command = self._sock_recv(1)
  File "/opt/homebrew/lib/python3.10/site-packages/paho/mqtt/client.py", line 640, in _sock_recv
    return self._sock.recv(bufsize)
TimeoutError: [Errno 60] Operation timed out

and check the code:

image
class ConnectionError(OSError): ...

Looks fine, But it is none. So I add this code:

image

It works.

image

This is not the same as described in the previous issue #291 and #288 , why?

MattBrittan commented 8 months ago

PR #710 has been (partly!) committed and should resolve this. I'm going to flag the issue as completed (would appreciate confirmation that the issue is resolved).

Note: This is part of an exercise to clean up old issues so that the project can move forwards. Due to the number of issues being worked through mistakes will be made; please feel free to reopen this issue (or comment) if you believe it's been closed in error.