mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-08 12:23:47 +00:00
Enforce a minimum SSE reconnect wait to avoid a busy loop (#2592)
SSEClient::wait_for_reconnect() sleeps in 100ms steps until the reconnect interval has elapsed. With an interval of 0 (for example "retry: 0" from the server, or set_reconnect_interval(0)) it never slept at all, so a server that sends "retry: 0" and closes the stream made the client reconnect in a tight loop. set_max_reconnect_attempts() does not stop this either, because each successful connection resets the attempt counter. Always wait at least one step (100ms). Intervals of 1-99ms already waited 100ms because of the step size, so only 0 and negative values change behavior.
This commit is contained in:
@@ -69,7 +69,7 @@ sse.on_error([](httplib::Error err) { });
|
||||
#### Configuration
|
||||
|
||||
```cpp
|
||||
// Set reconnect interval (default: 3000ms)
|
||||
// Set reconnect interval (default: 3000ms, minimum: 100ms)
|
||||
sse.set_reconnect_interval(5000);
|
||||
|
||||
// Set max reconnect attempts (default: 0 = unlimited)
|
||||
|
||||
Reference in New Issue
Block a user