AzNetworking (Windows): dead clients stall a server's UdpReaderThread; every connection's packets arrive seconds late, and moves/connects fail
Describe the bug On Windows, a UDP server that keeps sending to clients that went away (crashed or killed, until their connection times out) falls seconds behind on every other client's incoming packets.
- Windows reports each ICMP port-unreachable as
WSAECONNRESET(10054) on the socket's nextrecvfrom, unlessSIO_UDP_CONNRESETis turned off. AzNetworking does not turn it off. UdpSocket::Receivereturns 0 for it (net_UdpIgnoreWin10054, default true), the same as "no more data".UdpReaderThread::OnUpdatestops reading that socket at the first 0 until its next update (10 ms).- So each such error costs a whole reader update. A server sending to a few dead clients every tick queues the real packets behind the errors.
Knock-on effects:
- Live clients get timed out.
- A client's connect packet arrives seconds late, and its stale ClientHello is answered after the
client has started a new attempt. The client fails with
RSA_verify_PKCS1_PSS_mgf1: bad signature. - A server connection created from a stale resend can then stay stuck mid-handshake forever (separate issue).
Steps to reproduce
- A dedicated server on Windows and a dozen clients (headless is fine) connected to it, DTLS on or off.
- Kill some clients' processes (no disconnect sent), so the server keeps sending to their ports until
net_UdpDefaultTimeoutMs. - Meanwhile connect or migrate other clients to that server.
Expected behavior Dead peers cost nothing but their own timeout; other clients' packets are read as they arrive.
Actual behavior Measured with 10 connected clients, 4 of them killed in two waves (their processes stopped), and the clients moving between three servers every 10 s (240 s per run, loopback):
| receive errors on the server | moves that failed | failed DTLS handshakes | move wait p95 | |
|---|---|---|---|---|
| unpatched, run 1 | 3,142 | 25 | 6 | 4,700 ms |
| unpatched, run 2 | 3,561 | 47 | 9 | 4,700 ms |
SIO_UDP_CONNRESET off, run 1 |
0 | 0 | 0 | 666 ms |
SIO_UDP_CONNRESET off, run 2 |
0 | 0 | 0 | 500 ms |
All failed moves went to the one server that had the dead clients.
Fix used
In UdpSocket::Open, on Windows:
WSAIoctl(socket, SIO_UDP_CONNRESET, &FALSE, ...). Nothing in AzNetworking uses the reports;
connections time out on their own. We added net_UdpWinConnReset (default false) to restore the old
behaviour for comparison.
A second option: make UdpReaderThread keep reading after an ignored 10054 instead of stopping (that
needs Receive to tell "error, ignored" apart from "no data").
Desktop/Device Windows 11, O3DE 26.05 (2605.0 source build of AzFramework), loopback.
Source: o3de/o3de