libwebsockets icon indicating copy to clipboard operation
libwebsockets copied to clipboard

secs_since_valid_ping max value

Open a2576014760 opened this issue 9 months ago • 4 comments

When I set the interval secs_since_valid_ping to 0xffff, I keep reconnecting. Why?

a2576014760 avatar Mar 31 '25 01:03 a2576014760

You can set the conceal count to LWS_RETRY_CONCEAL_ALWAYS which is 0xffff. But the secs_since_valid_ping doesn't particularly understand 0xffff (it's a uint16_t). Assuming you mean it is constantly disconnecting under those conditions, does the problem still come with 0x7fff or 0x8000?

lws-team avatar Mar 31 '25 06:03 lws-team

Only when it is set to 0xffff will the connection be disconnected. Other values are fine. Moreover, the definition of LWS_RETRY_CONCEAL_ALWAYS is 0xffff. I guess it might be related to the parameter secs_since_valid_hangup. How should I set these two parameters?

a2576014760 avatar Mar 31 '25 08:03 a2576014760

I guess it might be related to the parameter secs_since_valid_hangup

No, as I said

You can set the conceal count to LWS_RETRY_CONCEAL_ALWAYS which is 0xffff

That is related to how many times it should try to reconnect before failing... for that member, 0xffff means never "fail" but keep retrying forever.

Why 0xffff has a bad effect for the secs_since_valid_ping I dunno. But you can just use 0xfffe and all is well according to what I understood, so is it a problem?

lws-team avatar Mar 31 '25 09:03 lws-team

I found that in my code secs_since_valid_hangup is secs_since_valid_ping fixed plus 10, and when set to 0xffff, it is reversed, so I should avoid setting the size of secs_since_valid_ping greater than 0xfff5. Also, when I set the "conceal count" parameter to LWS_RETOMY_CONCEAL_ALWAYS, as you said, no disconnection will occur.

a2576014760 avatar Mar 31 '25 09:03 a2576014760