You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Creating a client and connecting to a non-existent endpoint doesn't timeout as expected. It just hangs/cycles.
To Reproduce
from socketio import Client
sio = Client(engineio_logger=True)
print("attempting to connect...")
sio.connect(
"http://localhost:7777",
retry=5,
wait=True,
wait_timeout=1,
)
print("connected.")
I was testing this using a websocket transport, but that doesn't matter. I also increased the wait_timeout to 10, but that didn't seem to change anything. I don't see where the wait_timeout is being respected.
Expected behavior
I expect it to timeout as opposed to blocking indefinitely.
Logs
Attempting polling connection to http://localhost:7777/socket.io/?transport=polling&EIO=4
HTTP GET request to http://localhost:7777/socket.io/?transport=polling&EIO=4&t=1740072292.5999632 failed with error HTTPConnectionPool(host='localhost', port=7777): Max retries exceeded with url: /socket.io/?transport=polling&EIO=4&t=1740072292.5999632 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fdcdb587d10>: Failed to establish a new connection: [Errno 111] Connection refused')).
This continues indefinitely, printing that error message about once per second.
The text was updated successfully, but these errors were encountered:
I think you are mixing up timeouts at different levels of the stack.
The wait_timeout that you are using is not a timeout for a low-level (ie. HTTP) connection. This is a timeout for the Socket.IO handshake, once the low-level connection is established. The reason for this timeout is that this handshake can take some time, depending on the application and the number of namespaces used. Here are the definitions of the wait and wait_timeout arguments, copied from the documentation:
wait – if set to True (the default) the call only returns when all the namespaces are connected. If set to False, the call returns as soon as the Engine.IO transport is connected, and the namespaces will connect in the background.
wait_timeout – How long the client should wait for the connection. The default is 1 second. This argument is only considered when wait is set to True.
Based on your description you are connecting to a non-existing endpoint. If you want non-default retry logic and timeouts at that level, then you have to define your own customized HTTP client session. See the http_session argument that is passed in the constructor of the Client object. Docs copied below for your convenience:
http_session – an initialized requests.Session object to be used when sending requests to the server. Use it if you need to add special client options such as proxy servers, SSL certificates, custom CA bundle, etc.
Describe the bug
Creating a client and connecting to a non-existent endpoint doesn't timeout as expected. It just hangs/cycles.
To Reproduce
I was testing this using a websocket transport, but that doesn't matter. I also increased the wait_timeout to 10, but that didn't seem to change anything. I don't see where the
wait_timeout
is being respected.Expected behavior
I expect it to timeout as opposed to blocking indefinitely.
Logs
This continues indefinitely, printing that error message about once per second.
The text was updated successfully, but these errors were encountered: