wifi stops connecting after few unsuccessful connection attempts


I am connecting to a server via connectSSL.
if the server is online everything works repeatedly.
if the server drops for a short while (only few timedout connectSSL calls) and comes back online then it works
but if the server remains out for a longer while, then the connectSSL fails to reconnect when the server comes back online.

curiously this can be seen in timeout durations also.
the connection attemps take 28 secs until they timeout normally.
after a few failed ones, they start to take 10secs and then the connection will no longer success when the server is back online.
as far as I have understood, the timeout consists of 18 secs in void SpiDrv::waitForSlaveReady()
and 10secs in connectSSL:
unsigned long start = millis();

// wait 4 second for the connection to close
while (!connected() && millis() - start < 10000)

when the failing starts, the SpiDrv::waitForSlaveReady() starts to be almost immediate.

is there anyway to force a reset to the wifi module?

I tried wifi disconnect/connect already, did not help.


seems to be connectSSL specific. normal connect does not have this problem.

and to answer my question: WiFiClass::end() does the necessary reset. and then you need to reconnect to the WiFi.

this seems to be a workaround for the problem.

// o-p