diff --git a/Microsoft.Azure.Amqp/Amqp/Transport/TcpTransportInitiator.cs b/Microsoft.Azure.Amqp/Amqp/Transport/TcpTransportInitiator.cs index 3b81ea99..4234cf70 100644 --- a/Microsoft.Azure.Amqp/Amqp/Transport/TcpTransportInitiator.cs +++ b/Microsoft.Azure.Amqp/Amqp/Transport/TcpTransportInitiator.cs @@ -64,6 +64,10 @@ static void OnConnectComplete(object sender, SocketAsyncEventArgs e) { thisPtr.Complete(e, false); } + else + { + e.ConnectSocket?.Dispose(); + } } static void OnTimer(object obj) @@ -83,9 +87,9 @@ void Complete(SocketAsyncEventArgs e, bool completeSynchronously) if (e.SocketError != SocketError.Success) { exception = new SocketException((int)e.SocketError); - if (e.AcceptSocket != null) + if (e.ConnectSocket != null) { - e.AcceptSocket.Dispose(); + e.ConnectSocket.Dispose(); } } else