Skip to content
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

Increase default timeout for WiFiClient from 3ms to 3s #5496

Merged
merged 1 commit into from
Aug 11, 2021

Conversation

drzony
Copy link
Contributor

@drzony drzony commented Aug 4, 2021

Summary

#5487 introduced a default timeout for WiFiClient, however the default was specified in milliseconds instead of seconds, see be84c82#commitcomment-54358731
This 3ms timeout breaks OTA when the processor is busy.

Impact

Sets the default to a saner value, fixes OTA.

@CLAassistant
Copy link

CLAassistant commented Aug 4, 2021

CLA assistant check
All committers have signed the CLA.

drzony referenced this pull request Aug 4, 2021
)

## The problem
WiFiClient's connect method variant where no timeout is passed can block esp32 MCU and may then cause watchdog to kick in and reset the device. This behavior is different from that, what is in arduino-esp8266 core.

## Summary
Some cross-esp libraries (working both on esp32 and 8266), like PubSubClient simply call connect method on WiFiClient, to get connected to remote server. However, connect behavior varies betwen esp arduino 8266 and esp arduino 32 cores. This pull request tries introduce same behavior - to make connect method non-blocking on esp32, like it is with 8266 arduino core.

## Proposed solution
Introduce default fixed timeout that can be changed by #define - by default set to 3 seconds.

### Affected components: 
WiFiClient

### Affected methods:
```c++ 
int connect(IPAddress ip, uint16_t port);
int connect(const char *host, uint16_t port);
```

### Impact
May impact projects or libraries using connect method variant without specified timeout, where:
- remote is located far away or
- connection is heavily limited, or
- remote is slow, when it comes to accept the connection
@drzony drzony force-pushed the fix-wificlient-timeout branch from 67de627 to 511efdc Compare August 6, 2021 08:18
@me-no-dev me-no-dev merged commit 0acbe78 into espressif:master Aug 11, 2021
@me-no-dev
Copy link
Member

@drzony thanks for fixing this :)

@cziter15
Copy link
Contributor

cziter15 commented Aug 26, 2021

Thank you so much Drzony for spotting this and sorry for my initial mistake :)

It worked for me connecting MQTT server at my test setup, but probably connection was fast enough to not trigger this issue.

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.

5 participants