I'm making a simple app that uses socketIO_client. I can't figure out how to "catch" the error when the connection fails.
from socketIO_client import SocketIO, LoggingNamespace
sock = SocketIO("localhost", 3000, LoggingNamespace)
When the server is offline the following is printed in the console:
WARNING:root:localhost:3000/socket.io [waiting for connection] HTTPConnectionPool(host='localhost', port=3000): Max retries exceeded with url: /socket.io/?EIO=3&transport=polling&t=1455989769325-0 (Caused by <class 'ConnectionRefusedError'>: [Errno 111] Connection refused)
But an exception isn't raised that I can catch and I tried creating my own namespace class with on_error
, on_disconnect
, and on_event
functions defined but none of them were executed. This answer didn't work either.
How can I "catch" this error so I can handle it properly? Alternatively, where can I find more detailed documentation? Thanks!