Closing exception

Mar 22, 2012 at 11:16 PM

When my application is closing, I call webSocket.Close().  But I got an exeption.  Is there something I should do before closing the webSocket?

 

Web socket error: System.IO.IOException: Unable to read data from the transport connection: Cannot access a disposed object.

Object name: 'System.Net.Sockets.Socket'.. ---> System.ObjectDisposedException: Cannot access a disposed object.

Object name: 'System.Net.Sockets.Socket'.

at System.Net.Sockets.Socket.BeginReceive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, SocketError& errorCode, AsyncCallback callback, Object state)

at System.Net.Sockets.Socket.BeginReceive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state)

at System.Net.Sockets.NetworkStream.BeginRead(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)

--- End of inner exception stack trace ---

at System.Net.Sockets.NetworkStream.BeginRead(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)

at System.Net.FixedSizeReader.StartReading()

at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)

at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)

at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)

at System.Net.Security._SslStream.BeginRead(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback asyncCallback, Object asyncState)

at System.Net.Security.SslStream.BeginRead(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback asyncCallback, Object asyncState)

at SuperSocket.ClientEngine.SslStreamTcpSession.BeginRead()

 

Thank you.

Coordinator
Mar 23, 2012 at 3:41 AM

You can ignore this exception, I 'll do it in WebSocket4Net.

Coordinator
Apr 3, 2012 at 5:35 PM

Hi, this exception has been ignored, could you download the latest source code?

May 2, 2012 at 5:15 PM
Edited May 2, 2012 at 5:16 PM

I downloaded the latest build (4/18).   I still got WebSocket_Error event handler is called after the WebSocket_Close event handler is called.   Here is the exception that is received from WebSocket_Error

 

 

Object name: 'System.Net.Sockets.Socket'.. ---> System.ObjectDisposedException: Cannot access a disposed object.

Object name: 'System.Net.Sockets.Socket'.

at System.Net.Sockets.Socket.BeginReceive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, SocketError& errorCode, AsyncCallback callback, Object state)

at System.Net.Sockets.Socket.BeginReceive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state)

at System.Net.Sockets.NetworkStream.BeginRead(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)

--- End of inner exception stack trace ---

at System.Net.Sockets.NetworkStream.BeginRead(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)

at System.Net.FixedSizeReader.StartReading()

at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)

at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)

at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)

at System.Net.Security._SslStream.BeginRead(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback asyncCallback, Object asyncState)

at System.Net.Security.SslStream.BeginRead(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback asyncCallback, Object asyncState)

at SuperSocket.ClientEngine.SslStreamTcpSession.BeginRead()

Should I just ignore the exception after the websocket is closed.

Thanks.

 

 

Coordinator
May 2, 2012 at 5:22 PM

Yes, just ignore it. I think I have resolved it on April, 20th. 

http://clientengine.codeplex.com/SourceControl/changeset/changes/343ac6fe66b3

http://websocket4net.codeplex.com/SourceControl/changeset/changes/3f77b10141fd