Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Core 2.0.3 WiFiClient breaks timeouts #6918

Unanswered
Xylopyrographer asked this question in Q&A
Discussion options

I'm migrating code from arduino-esp32 core v1.0.6 to core v2.0.3.

Part of what broke is this bit of (highly simplified) code:

WiFiClient stClient;
IPAddress stIP;
uint16_t stPort;
if ( stClient.connect(stIP, stPort, 100) ) { // try to connect to the server, waiting up to 100 ms
 // do things...
}

The above connects 100% of the time under 1.0.6. but under 2.0.3 it fails 100%.

Using v2.0.3, I could only get it to connect if I left out the timeout parameter, as in:

if ( stClient.connect(stIP, stPort ) ) { // try to connect to the server, waiting up to 100 ms
 // do things...
}

or if I set the timeout parameter value to at least 1000 as in:

if ( stClient.connect(stIP, stPort, 1000) ) { // try to connect to the server, waiting up to 100 ms
 // do things...
}

So I compared the WiFClient.h and WiFiClient.cpp files from core versions 1.0.6 and 2.0.3.

Of the changes to the v2.0.3 .cpp file, a number have to do with the way the timeout or _timeout parameter is used, which make it not backward compatible with the core v1.0.6 implementation.

It seems that in v2.0.3 timeout is now a value of seconds instead of ms (but why do we need a uint32_t value for that??). Internal to WiFiClient.cpp a default timeout of 3000ms is used? Why the breaking change in the timeout parameter in the call to .connect? Or am I missing something?

If everything has to be in seconds (though why??) under 2.0.3 shouldn't any value of timeout less than 1000 throw an error during compile? Or at least a warning? Or use a run-time logw in the .cpp?

Regardless, is there a summary somewhere, relative to core 1.0.6, of the way timeout (for all WiFiClient methods) is used in core 2.0.3?

And an opportunity for improvement -- do the release notes for new core releases track breaking changes? Would be nice (and save hours of debugging) if they did 😄.

Philosophically related to #6835?

You must be logged in to vote

Replies: 2 comments

Comment options

Yes, exactly connected to #6835 which because of the breaking changes we have left for 2.1.0

You must be logged in to vote
0 replies
Comment options

I re-read #6835 and #6676.

In core v1.0.6, timeouts were in milliseconds. And if I understand, in other espressif cores (8266) and in Arduino they are in milliseconds.

In core v2.0.3 they are now in seconds. Why the change?

Especially weird as in v2.0.3 it makes no sense to pass anything other that integer multiples of exactly 1000 as a timeout value, and anything less than 1000 is now equal to 0.

And to ask again, could 2.0.4 at least add a logw() message and a compiler warning that things are very different in core 2.x? Especially given it was known that the new release was going to break existing code based on 1.0.6. It would save hours of debugging chasing down a thing that was broken but not reported as breaking.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /