Socket timeout not honored with SSL
Has anyone faced issues with socket timeouts when using HTTPS connections?
version='v1.8.6-849-df9f237 on 2019-05-14'
machine='GPy with ESP32'
When configuring a socket to use a timeout, if the socket has been wrapped with the
ussl.wrap_socketmethod, the timeout is not honored.
Given a socket
sockwhich has been successfully connected to a host, trying to call
Noneif the timeout is reached and there is nothing to read in the socket:
import usocket sock = usocket.socket() sock.settimeout(5) sock.connect((host, port)) t = sock.read(1) # after timeout, t is None print(t is None)
But when the socket is wrapped with
ussl, the timeout setting is ignored and
import usocket import ussl sock = usocket.socket() sock = ussl.wrap_socket(sock) sock.settimeout(5) sock.connect((host, port)) # this hangs indefinitely t = sock.read(1)
This also happens at least for the
Take a look at this issue on Github: