From 9b56ff520f85d703cfc661887fea04b3da5a4177 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Fri, 21 Apr 2023 20:43:33 -0500 Subject: [PATCH] update to cod rcon parser for windows socket quirk with UDP WSAECONNRESET --- Integrations/Cod/CodRConConnection.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Integrations/Cod/CodRConConnection.cs b/Integrations/Cod/CodRConConnection.cs index de5e9f4ba..b670e6ba1 100644 --- a/Integrations/Cod/CodRConConnection.cs +++ b/Integrations/Cod/CodRConConnection.cs @@ -125,7 +125,7 @@ namespace Integrations.Cod } catch (OperationCanceledException) { - _log.LogDebug("Waiting for flood protect did not complete before timeout timeout {Count}", + _log.LogDebug("Waiting for flood protect did not complete before timeout {Count}", connectionState.OnComplete.CurrentCount); throw new RConException("Timed out waiting for flood protect to expire", true); } @@ -375,8 +375,18 @@ namespace Integrations.Cod private async Task ReceiveAndStoreSocketData(Socket rconSocket, CancellationToken token, ConnectionState connectionState) { - var result = await rconSocket.ReceiveFromAsync(connectionState.ReceiveBuffer, - SocketFlags.None, Endpoint, token); + SocketReceiveFromResult result; + try + { + result = await rconSocket.ReceiveFromAsync(connectionState.ReceiveBuffer, + SocketFlags.None, Endpoint, token); + } + // windows quirk that occurs when remote server returns ICMP port unreachable + catch (SocketException ex) when (ex.SocketErrorCode == SocketError.ConnectionReset) + { + await Task.Delay(Timeout.Infinite, token); + return; + } if (result.ReceivedBytes == 0) {