kerryjiang / WebSocket4Net

A popular .NET WebSocket Client
752 stars 272 forks source link

SocketNotConnected exception from PING #18

Open codeknox opened 9 years ago

codeknox commented 9 years ago

I think this could be handled better.

I'm doing a lot of tests of network tolerance on our app and from time to time I get the below call stack on an exception. As it originates from a Ping on another thread not under my control, it just goes straight to unhandled exception.

Any way to make this better?

at SuperSocket.ClientEngine.TcpClientSession.DetectConnected() at SuperSocket.ClientEngine.TcpClientSession.TrySend(ArraySegment1 segment) at SuperSocket.ClientEngine.ClientSession.Send(ArraySegment1 segment) at SuperSocket.ClientEngine.ClientSession.Send(Byte[] data, Int32 offset, Int32 length) at WebSocket4Net.Protocol.DraftHybi10Processor.SendDataFragment(WebSocket websocket, Int32 opCode, Byte[] playloadData, Int32 offset, Int32 length) at WebSocket4Net.Protocol.DraftHybi10Processor.SendMessage(WebSocket websocket, Int32 opCode, String message) at WebSocket4Net.Protocol.DraftHybi10Processor.SendPong(WebSocket websocket, String pong) at WebSocket4Net.Command.Ping.ExecuteCommand(WebSocket session, WebSocketCommandInfo commandInfo) at WebSocket4Net.WebSocket.ExecuteCommand(WebSocketCommandInfo commandInfo) at WebSocket4Net.WebSocket.OnDataReceived(Byte[] data, Int32 offset, Int32 length) at WebSocket4Net.WebSocket.client_DataReceived(Object sender, DataEventArgs e) at SuperSocket.ClientEngine.ClientSession.OnDataReceived(Byte[] data, Int32 offset, Int32 length) at SuperSocket.ClientEngine.SslStreamTcpSession.OnDataRead(IAsyncResult result) at System.IO.Stream.ReadWriteTask.InvokeAsyncCallback(Object completedTask) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.IO.Stream.ReadWriteTask.System.Threading.Tasks.ITaskCompletionAction.Invoke(Task completingTask) at System.Threading.Tasks.Task.FinishContinuations() at System.Threading.Tasks.Task.FinishStageThree() at System.Threading.Tasks.Task.FinishStageTwo() at System.Threading.Tasks.Task.Finish(Boolean bUserDelegateExecuted) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot) at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution) at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

kerryjiang commented 9 years ago

I thought this exception had been fixed long days ago?