diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs index 666c38fa75..462201ead7 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs @@ -563,7 +563,8 @@ private static async void ParallelConnectHelper( { // Try to connect. If we're successful, store this task into the result task. await connectTask.ConfigureAwait(false); - success = tcs.TrySetResult(socket); + // A connection attempt could return quickly if a server refuses connection or there is some other error + success = socket.Connected && tcs.TrySetResult(socket); if (success) { // Whichever connection completes the return task is responsible for disposing