Commit 7be299a
committed
fix(rtc): auto-reconnect signaling WebSocket on unexpected loss
`WebSocketClient` had no reconnect logic of its own — `_on_close`,
`_on_error`, and the health-check timeout in `_ping_loop` only logged
and stopped the connection. When the signaling WS dropped (transient
TCP reset, missed health check, server-side close without an SFU error
event), the session sat hanging until the frontend's own timeout fired
a DELETE.
Under concurrent load this is the dominant remaining cause of "the
agent disconnected randomly" reports: even with the late-offer fix in
place, a single brief WS blip is fatal because nothing kicks
reconnection.
- `signaling.py`: emit a `connection_lost` event with a reason string
on (a) unexpected `_on_close`, (b) `_on_error` after the initial
handshake completed, and (c) `_ping_loop` health-check timeout
(notify *before* `self.close()` so the user-initiated guard does not
suppress it). Idempotent via `_connection_lost_sent`.
- `connection_manager.py`: subscribe to `connection_lost` on the WS
client and route it into the existing `ReconnectionManager`
(`ReconnectionStrategy.FAST`). The manager already handles strategy
escalation, locking, and the disconnection-timeout deadline.1 parent 2b1e111 commit 7be299a
2 files changed
Lines changed: 65 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
269 | 288 | | |
270 | 289 | | |
271 | 290 | | |
| |||
403 | 422 | | |
404 | 423 | | |
405 | 424 | | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
406 | 434 | | |
407 | 435 | | |
408 | 436 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
217 | 221 | | |
218 | 222 | | |
219 | 223 | | |
220 | 224 | | |
| 225 | + | |
221 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
222 | 254 | | |
223 | 255 | | |
224 | 256 | | |
| |||
242 | 274 | | |
243 | 275 | | |
244 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
245 | 281 | | |
246 | 282 | | |
247 | 283 | | |
| |||
0 commit comments