This project is read-only.

getting an exception

Oct 27, 2012 at 11:52 AM

Hi,

 

getting the following exception :

2012-10-27 12:35:07,914 [260] FATAL AppManager:OnUnhandledException [(null)] - ERROR : OnUnhandledException Event caught !!! : e = System.NullReferenceException: Object reference not set to an instance of an object.
   at SocketIOClient.Client.OnMessageEvent(IMessage msg) in f:\CodePlex\socketio4net\SocketIO\Client.cs:line 326
   at SocketIOClient.Client.wsClient_OpenEvent(Object sender, EventArgs e) in f:\CodePlex\socketio4net\SocketIO\Client.cs:line 404
   at WebSocket4Net.WebSocket.OnHandshaked()
   at WebSocket4Net.Command.Handshake.ExecuteCommand(WebSocket session, WebSocketCommandInfo commandInfo)
   at WebSocket4Net.WebSocket.ExecuteCommand(WebSocketCommandInfo commandInfo)
   at WebSocket4Net.WebSocket.OnDataReceived(Byte[] data, Int32 offset, Int32 length)
   at SuperSocket.ClientEngine.AsyncTcpSession.ProcessReceive(SocketAsyncEventArgs e)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)
   at System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

 

running on windows server 2008 r2 (64 bit),

socketioclient.dll = 6.26

newtonsoft.json.dll 4.5.9.15308

 

my server is running and then crash for this exception,

can't think of a way to reproduce it.

Coordinator
Oct 27, 2012 at 4:01 PM

I looks like you are getting a message after you have called client.Close().  I will protect the message emitter from this in the next release, but as a workaround, you can try/catch around that exception and ignore - since your closing the client anyway.

At 326, the only way this.registrationManager is ever set to null is in  the Close method.

 

Jim

Oct 27, 2012 at 4:34 PM

this could be the Close method.

I have a problem, where sometime there is a disconnection on the other side, and i reach the "retry" callback - but sometimes it fails to reconnect.

 

I'm doing something like :

try {

socket.Close();

socket.Dispose();

socket = null;

}

 

anything you can help me with ?

1. failures of reconnect

2. am i closing it correctly per the example above ?

 

thanks in advance

Coordinator
Oct 27, 2012 at 5:30 PM

Are you calling Close() after the Retry message or the SocketConnectionClosed event?  It sounds like your are working off the Retry - but that is really only more of a warning type message - rather than a full connection failure (The client will attempt to reconnect on its own a default of 3x).  My impression from your description is such that because you are getting a message (indicated by the thrown exception message), the connection is indeed live (reconnected) and not disconnected.

Do you have any trace outputs of the event sequences that you can share?

Assuming you are getting a SocketConnectionCloded event - calling Close() and setting socket=null is fine.

Oct 28, 2012 at 8:26 AM

Hi,

 

I will check that the socket is not null before the Close(), that was probably the reason.

Yet, will be good if you'd prevent this error on your side as well.

 

The problem i have is that i'm getting some SocketConnectionRetryAttempt from time to time, which is in general fine,

but sometimes cannot recover from it - not reaching to the SocketOpened,

and only restarting my application works.

 

appreciate if you have any idea how it can happen, or if you need any extra info from me in order to investigate it.

 

regards