diff --git a/SimpleSockets/Client/SimpleSocketTcpSslClient.cs b/SimpleSockets/Client/SimpleSocketTcpSslClient.cs index ac747dd..834ab8e 100644 --- a/SimpleSockets/Client/SimpleSocketTcpSslClient.cs +++ b/SimpleSockets/Client/SimpleSocketTcpSslClient.cs @@ -388,13 +388,19 @@ protected override async void ReceiveCallback(IAsyncResult result) } catch (Exception ex) { - DisposeSslStream(); RaiseErrorThrown(ex); - _mreReceiving.Set(); - _mreRead.Set(); - state.Reset(); - // Receive(state); + if (!Disposed) + { + DisposeSslStream(); + if (_mreReceiving != null) + _mreReceiving.Set(); + if (_mreRead != null) + _mreRead.Set(); + state.Reset(); + } + } + } #endregion diff --git a/Tests/Test.Sockets.Parallel/TcpSslParallelTests.cs b/Tests/Test.Sockets.Parallel/TcpSslParallelTests.cs index 17e2f51..c0f8a74 100644 --- a/Tests/Test.Sockets.Parallel/TcpSslParallelTests.cs +++ b/Tests/Test.Sockets.Parallel/TcpSslParallelTests.cs @@ -17,7 +17,7 @@ public class TcpSslParallelTests private IList _clients = new List(); - private int _numClients = 25; + private int _numClients = 15; private int _numMessages = 1000; private X509Certificate2 _cert;