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

Change TCP timeout #661

Open
fabianoriccardi opened this issue Apr 22, 2021 · 2 comments
Open

Change TCP timeout #661

fabianoriccardi opened this issue Apr 22, 2021 · 2 comments

Comments

@fabianoriccardi
Copy link

fabianoriccardi commented Apr 22, 2021

Hi all,
will you add a method to change TCP timeout without manually altering the internal define WEBSOCKETS_TCP_TIMEOUT?

@Theagainmen
Copy link

Theagainmen commented Apr 28, 2021

I'm using some time critical functions on my ESP32 and I noticed that when it disconnects from the websocket server (ESP32 is the client) it is completely blocked for 5 seconds (=WEBSOCKETS_TCP_TIMEOUT). How can I make this part non-blocking? I don't think lowering this value is really the solution?
I thought this should be non blocking because the network stuff runs in core 0? Seems like it doesn't. Is it possible to either run this piece of code in core 0, or create a seperate task for this on core 1?

@adamczuk-piotr
Copy link

adamczuk-piotr commented May 6, 2022

Hi,
This WEBSOCKETS_TCP_TIMEOUT hardcoded to 5000 is really painfull.
Bloks whole application if websocket server fails, espesally if you set reconnect interval to 5 seconds also :).

Could someone explain why it's set to such huge value at all? Even few kB of data will not need such much time to be send in single message.

We can at least wrap it between #IFNDEF and allow to redifine for external configuration.
It might be better to to make it property of the class or even two of them.
It's used while connecting and should be really low by default
and the second one here:

 #if(WEBSOCKETS_NETWORK_TYPE != NETWORK_ESP8266_ASYNC)
    // set Timeout for readBytesUntil and readStringUntil
    _client.tcp->setTimeout(WEBSOCKETS_TCP_TIMEOUT);
#endif

This might need more adjustmenst depending on particular usage.

Third usage of this in

void WebSocketsClient::handleClientData(void) {
    if((_client.status == WSC_HEADER || _client.status == WSC_BODY) && _lastHeaderSent + WEBSOCKETS_TCP_TIMEOUT < millis()) {

is unknowm for me.

Anyway I will create fork to fix that at least for myself and waiting for any response with better default values.

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

No branches or pull requests

3 participants