From 77128adb5d3b44263c1a6d643b538f1db67ad318 Mon Sep 17 00:00:00 2001 From: demarco Date: Tue, 24 Mar 2026 08:59:17 +0100 Subject: [PATCH] fix: remove KeepAlive setting from socket connection --- src/Testcontainers/Containers/ResourceReaper.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Testcontainers/Containers/ResourceReaper.cs b/src/Testcontainers/Containers/ResourceReaper.cs index 910062a13..0495a2dee 100644 --- a/src/Testcontainers/Containers/ResourceReaper.cs +++ b/src/Testcontainers/Containers/ResourceReaper.cs @@ -304,7 +304,8 @@ await Task.Delay(TimeSpan.FromSeconds(RetryTimeoutInSeconds), CancellationToken. using (var tcpClient = new TcpClient()) { - tcpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true); + // On some plateform the connection fail with PlatformNotSupportedException: Sockets on this platform are invalid for use after a failed connection attempt. + // tcpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true); tcpClient.LingerState = DiscardAllPendingData; try