The hand-rolled WebSocket client (ws_client.nim) uses blocking socket.recv() with no timeout. If the server disappears without sending a close frame (network flap, server crash), the main thread hangs indefinitely. No logs, no error, no recovery. The bot becomes a silent corpse.
Solution
Set SO_RCVTIMEO on the socket via socket.setSockOpt(OptRcvTimeo, timeout) and add error handling when receive times out — detect disconnection, log it, and clean up gracefully.
## Problem
The hand-rolled WebSocket client (`ws_client.nim`) uses blocking `socket.recv()` with no timeout. If the server disappears without sending a close frame (network flap, server crash), the main thread hangs indefinitely. No logs, no error, no recovery. The bot becomes a silent corpse.
## Solution
Set `SO_RCVTIMEO` on the socket via `socket.setSockOpt(OptRcvTimeo, timeout)` and add error handling when receive times out — detect disconnection, log it, and clean up gracefully.
## Files
- `src/robocode_tankroyale_botapi/ws_client.nim`
- `src/robocode_tankroyale_botapi/bot.nim` (receive loop error handling)
Fixed in v1.0.2. Added 30s SO_RCVTIMEO on WebSocket socket via stdlib timeout overload. 5 consecutive timeouts trigger disconnect. Validated with 3-round battle test — no false positives during normal gameplay.
Fixed in v1.0.2. Added 30s SO_RCVTIMEO on WebSocket socket via stdlib timeout overload. 5 consecutive timeouts trigger disconnect. Validated with 3-round battle test — no false positives during normal gameplay.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem
The hand-rolled WebSocket client (
ws_client.nim) uses blockingsocket.recv()with no timeout. If the server disappears without sending a close frame (network flap, server crash), the main thread hangs indefinitely. No logs, no error, no recovery. The bot becomes a silent corpse.Solution
Set
SO_RCVTIMEOon the socket viasocket.setSockOpt(OptRcvTimeo, timeout)and add error handling when receive times out — detect disconnection, log it, and clean up gracefully.Files
src/robocode_tankroyale_botapi/ws_client.nimsrc/robocode_tankroyale_botapi/bot.nim(receive loop error handling)Fixed in v1.0.2. Added 30s SO_RCVTIMEO on WebSocket socket via stdlib timeout overload. 5 consecutive timeouts trigger disconnect. Validated with 3-round battle test — no false positives during normal gameplay.