Closed GoogleCodeExporter closed 9 years ago
It seems that you've send messages while the socket is disconnected, just check
your
code and figure out why this happens.
Original comment by freezing...@gmail.com
on 8 Jan 2009 at 1:57
Original comment by hepha...@gmail.com
on 23 Jan 2009 at 5:35
Just wanted to let you all know my results with this.
1. User enters message to send.
2. Calling code verifies that socket is still connected.
3. Socket Disconnects.
4. Calling code tries to send message.
Exception occurs.
And there is no way for the calling code to prevent these.
I run a testing system that runs a stress-test program to simulate a loaded-down
system, and it can take 50-500 ms to execute between steps 2 and 4. If the
socket
disconnects anywhere in that window, an unhandled exception is thrown. I had
to hack
MSNPSharp a bit to fix it:
protected void SendSocketData(byte[] data)
{
if (socket == null || !socket.Connected)
{
// the connection is closed
OnDisconnected();
return;
}
SendSocketData(this, data);
}
protected static void SendSocketData(SocketMessageProcessor processor, byte[]
data)
{
try
{
if (processor.socket != null)
lock (processor.socket)
{
processor.socket.Send(data);
}
}
catch (Exception e)
{
processor.OnDisconnected();
}
}
I'm not sure that it is proper to do this - it may cause other problems that I
can't
see. But I needed a better solution than ignoring these SocketExceptions in the
application unhandled error handler, and this solution seems to work.
Original comment by EricCoxH...@gmail.com
on 29 Jun 2009 at 7:54
Is psocket.Connected == true when you get that exception?
Original comment by freezing...@gmail.com
on 30 Jun 2009 at 6:52
ok,try r1067
Original comment by freezing...@gmail.com
on 30 Jun 2009 at 8:34
Thanks! I'll let you know how testing goes.
Original comment by EricCoxH...@gmail.com
on 30 Jun 2009 at 7:02
Original issue reported on code.google.com by
pengs...@gmail.com
on 8 Jan 2009 at 7:58