Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix ESP8266 driver behavior on connection failures #10377
In case the application calls
Furthermore, we did not make use of ESP8266 timeout message, because in fact it kept on trying to connect. Therefore we need to use our own timeout to return a proper error value if the connection really takes too long.
Pull request type
I had a talk with Kevin and my understanding is that giving up after 30 seconds in blocking mode should be fine. The rest of this comment you should read as my opinion.
Assumption here is that each connection attempt takes at maximum ~15 seconds(ESP8266_CONNECT_TIMEOUT). There is a 15 second grace period between the attempts with the current implementation. In other words please increase ESP8266_INTERFACE_CONNECT_TIMEOUT_MS to 30s+some seconds so that connect procedure has time to run two times if necessary.
That timelimit tells how long the driver has time to initiate a new connect-call, not when it should be done. It might still take 15 seconds(ESP8266_CONNECT_TIMEOUT) before the procedure succeeds or fails. So altogether it might take ~45 seconds that we know has the connection been established or did it fail.
I guess the grace period could be tuned down a bit from that 15 seconds so that the documentation can say we give up after 45 seconds. Return value should be something which makes possible to break out from the loop in blocking-mode.
@VeijoPesonen , thank you for this valuable comment. I fully agree with your opinion, I tried to embrace it in the code with the following line:
I hope this would make it cristal clear for anyone reading the code in the future what this timeout depends on and what to consider when adjusting it.