-
Notifications
You must be signed in to change notification settings - Fork 1.3k
TCP Connection Timeout Setting #8266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looks like it was intended, but as yet unimplemented:
|
Be able to set the connection timeout is crucial in That's actually a bummer as I'm porting the MiniMQTT lib to asyncio to get a fully non-blocking experience. So at least for the connection phase it won't be that "non-blocking" for now. In my case I would set the connection timeout very small and build a asyncio based retry mechanism on top. That would give other tasks time to run during connection failures. |
For reference: https://docs.python.org/3/library/socket.html#socket.socket.settimeout
The link to notes on socket timeouts says:
|
I did some research on this:
There are some code samples that make the socket be non-blocking and do their own timeout handling: |
In standard Python, socket.settimeout() sets a timeout for both TCP connections and data transfer. In CircuitPython, socket.settimeout() sets a timeout for data transfer, but doesn't affect the TCP connection timeout. It sure would be nice to set a TCP connection timeout, either via settimeout() or some other method.
For example, using CircuitPython 8.2.2 on an Adafruit Feather ESP32-S3 (no PSRAM), an attempted TCP connection always times out after 30 seconds, regardless of the settimeout() value. See below.
The example code output is "Connection timeout in 30.5 seconds." (give or take a couple of tenths), regardless of the settimeout() value.
The text was updated successfully, but these errors were encountered: