diff --git a/Graphite/CarbonConnectionPool.cs b/Graphite/CarbonConnectionPool.cs index c0de838..af28660 100644 --- a/Graphite/CarbonConnectionPool.cs +++ b/Graphite/CarbonConnectionPool.cs @@ -136,6 +136,12 @@ private async Task TestAsync(TcpClient client, CancellationToken cancellat try { await _formatter.TestConnectionAsync(client.GetStream(), cancellationToken).ConfigureAwait(false); + //https://stackoverflow.com/a/2661876/19671 + var socket = client.Client; + if (!socket.Connected) return false; + var poll = socket.Poll(1000, SelectMode.SelectRead); + var empty = socket.Available == 0; + if (poll && empty) return false; return true; } catch (IOException ex) when (ex.InnerException is SocketException se && CheckSocketException(se)) @@ -181,4 +187,4 @@ public bool Return(TcpClient obj) } } } -} \ No newline at end of file +}