Skip to content

Configurable timeout for WiFiClient connect and write operations #3257

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 4 commits into from
May 19, 2017

Conversation

igrr
Copy link
Member

@igrr igrr commented May 18, 2017

WiFiClient inherits Stream::setTimeout method. The value passed to setTimeout is used by Stream methods like readBytes, readStringUntil and so on. Other operations with WiFiClient such as connect and write previously didn't have configurable timeouts. connect would time out after 5 seconds, and write would return only if LwIP reported an error.

This change implements timeout during connect and write. For connect, same timeout value is used for name resolution and the actual connection, so it is possible that worst case timeout will be twice the timeout requested. For writes, write function will return the amount of data sent by the time the timeout has happened.

Fixes #1420, #3247, #2120

@igrr igrr merged commit 684b5f1 into master May 19, 2017
igrr added a commit that referenced this pull request May 22, 2017
WiFiClient write timeouts introduced in #3257 applied to the whole write
operation, which could take long time if data size was large. This
change makes the timeout happen per chunk. Timeout now happens if no
data has been delivered within a given interval.
@Jeroen88
Copy link
Contributor

Hi Ivan, how can I set the connect timeout for the ESP8266HTTPClient?

@aminjoharinia
Copy link

@Jeroen88 Did you found a solution?

@Jeroen88
Copy link
Contributor

@aminjoharinia Hi Amin, I think you can use void setTimeout(uint16_t timeout), this passes the timeout to the WiFiClient.

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.

3 participants