Skip to content

fix: Respecting connection timeout in WiFiClientSecure #5418

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

Merged
merged 1 commit into from
Jul 21, 2021

Conversation

vlastahajek
Copy link
Contributor

Closes #5398

Using the same non-blocking socket connect pattern for respecting connection timeout, copied from WiFiClient::connect.

WiFiClient::connect uses lwip_connect_r, whereas start_ssl_client uses lwip_connect. I haven't found what is the difference between them. I tested both, both work ok, so I kept lwip_connect.

@CLAassistant
Copy link

CLAassistant commented Jul 19, 2021

CLA assistant check
All committers have signed the CLA.

@vlastahajek vlastahajek force-pushed the fix/wificlsecure_timeout branch from a087d47 to da3cb81 Compare July 19, 2021 14:42
@me-no-dev
Copy link
Member

@david-cermak could you please have a look?

Copy link
Contributor

@david-cermak david-cermak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Yes, the correct way of handling connection timeout is to set the socket to the non-blocking mode and select() on its writeability.

Some consistency comments:

  • the code uses both lwip_... prefixed API (lwip-connect), as well as the standard posix like select() or close(). The former is faster, the latter is useful when writing generic code (e.g. with VFS), but in general better to stick to one API. On the other hand, this seems to be in line with the WiFiClient::connect, so it is consistent.
  • lwip_connect_r() was an old re-entrant function variant in older IDF's, but in all currently supported versions, the socket API is fully reentrant and thread safe.
  • As a side note: we typically switch the socket back to the blocking mode, after connect, so standard SO_RCVTIMEO and SO_SNDTIMEO options make sense, but this is in line with the previous code, as the socket was left in the non-blocking mode previously as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WiFiClientSecure: connection timeout not working
4 participants