When the server cuts a connection abruptly, the final notice or save-complete signal it sent is lost.
Why The server closes the connection with an abortive close (RST). This happens when SO_LINGER is set to 0 seconds, or when the socket is closed before all received data has been read → Effect The kick reason and final data still in transit are thrown away → On screen An unexplained “Connection closed due to an unknown error”
Send the reason, then close only the sending direction (shutdown), read incoming data until the other side closes and only then close the socket, avoid SO_LINGER of 0 seconds.
On the graph
Random spikes · Connections ended by RST
Where to look
Increase in TcpExtTCPAbortOnData (closed with RST while data was left to send, SO_LINGER 0 s) and TcpExtTCPAbortOnClose (closed with unread data left) from nstat -az, and whether a server-side packet capture at the moment of disconnect shows an RST going out where a FIN should be
Confirmed if
At the times of “Connection closed due to an unknown error” reports, the server sends RST, and AbortOnData and AbortOnClose rise
Ruled out if
Server closed normally with FIN, yet the reason still doesn’t show: the client’s close handling
Check with
Infra tools (no game code needed)
Sources
closesocket function (winsock.h)Microsoft Turning SO_LINGER on with a time of 0 makes close an abortive close that resets the connection immediately, and unsent data is lost
SNMP counterLinux kernel TcpExtTCPAbortOnData: closed with RST while data was left to send (SO_LINGER 0 s, for example); TcpExtTCPAbortOnClose: closed with unread data left, sending RST