Closing client after recive respond

May 4, 2013 at 6:37 PM
Hi,
I'm trying to move to new version, I make all the changes, and all compiled well.
But when I run the test app, and call a command (Connect), once server send respond, the client close (in debug, can't see anything), when run test from binarry I get app exit!!! why?

the server was sending :
SendJsonResponse(session, new ConCResponse
            {
                StatusCode = ResponseCode.SUCCESS,
                Token = session.SessionID
            });
now I changes it to:
        SendJsonMessage(session, new ConCResponse
            {
                StatusCode = ResponseCode.SUCCESS,
                Token = session.SessionID
            });
Once server call "SendJsonMessage" client closed.

client side:
  m_ClientWebSocket.Opened += (s, e) =>
            {
                var client = s as JsonWebSocket;
                client.Query<ConCResponse>(CommandKeys.CONNECT_CLIENT,
                    new ConCRequest
                    {
                        UserID = this.userID,
                    }, (r) => HandleConnCResponse(r, ClientToken_textBox));
            };
in client I see we get the message: ConCResponse:
System.Net.Sockets Verbose: 0 : [7696] Data from Socket#65677972::FinishOperation(ReceiveAsync)
System.Net.Sockets Verbose: 0 : [7696] 00000000 : 81 49 43 4F 4E 43 2D 35-37 32 37 20 7B 22 53 74 : .ICONC-5727 {"St
System.Net.Sockets Verbose: 0 : [7696] 00000010 : 61 74 75 73 43 6F 64 65-22 3A 30 2C 22 54 6F 6B : atusCode":0,"Tok
System.Net.Sockets Verbose: 0 : [7696] 00000020 : 65 6E 22 3A 22 30 65 36-66 38 31 33 37 2D 39 62 : en":"0e6f8137-9b
System.Net.Sockets Verbose: 0 : [7696] 00000030 : 66 64 2D 34 62 65 63 2D-39 38 66 30 2D 34 39 30 : fd-4bec-98f0-490
System.Net.Sockets Verbose: 0 : [7696] 00000040 : 63 62 37 30 32 63 61 36-63 22 7D                : cb702ca6c"}
The program '[960] WebSocketServer.TestWebSocketServer.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).
WHYYYYY?
Coordinator
May 6, 2013 at 4:03 PM
Could you try try to catch the unhandled exception in the client side?
May 6, 2013 at 4:36 PM
I dont see exception, I think socket4net maybe call EXIT
May 12, 2013 at 2:59 AM
I just replace the Socket4Net from binary zip. and it not closed, but I get error:
e.Exception.Message : "DeserializeObject exception"
why this now?
Coordinator
May 12, 2013 at 9:13 AM
Where did you get this exception?
May 12, 2013 at 4:30 PM
I must say, server have no errors, the error log is always empty. the exception is in client side (windows form).
I download again and replace all DLLs (websocket/socket4net..), and now back to prev issue , after server send the respond with status OK and token, client closed.

I'm sure there is some issues with the DLLs, can you add the engine.dll to the binary zip, since when i download the binary this file is missing, I take from reference, but seems something dlls ....
Again no errors !!!
Coordinator
May 12, 2013 at 4:47 PM
Please answer my question directly!

Where did you get this exception "e.Exception.Message : "DeserializeObject exception"?

If your client application shutdown unexpected, I suggest you add the line below to log the exception which causes the shutdown:

AppDomain.Current.UnhandledException += .....
May 12, 2013 at 4:58 PM
after replace again the DLL's the exception "DeserializeObject exception" not happen again.

but the unhandle exception that cause the app to close is:
ExceptionObject = {"Invalid cast from 'System.Int64' to 'WebSocketServer.Shared.ResponseCode'."}

why the hill this, I compile all as AnyCPU the RespondCode is:
public enum ResponseCode : int
{
    SUCCESS = 0,
    ALREADYCONNECT = 1,
    INVALID_ARGUMENTS,
    TIMEOUT,
    UNKOWN_ERROR,
};
May 12, 2013 at 5:04 PM
socket4net .dll is x64, and seems like mix between x64&x86 compilation :(
Coordinator
May 12, 2013 at 5:08 PM
Please answer my question directly!
Where did you get the exception? In client side or SuperWebSocket?
May 12, 2013 at 5:10 PM
I answered already, in server no error, it is in the client side!
Coordinator
May 12, 2013 at 5:14 PM
Edited May 12, 2013 at 5:16 PM
If you meet a JSON serializing/deserializing problem, you can overwrite the two method of JsonWebSocket below to change back to use JSON.NET:
protected virtual string SerializeObject(object target)
protected virtual object DeserializeObject(string json, Type type)

Similar with this file:
https://websocket4net.codeplex.com/SourceControl/latest#WebSocket4Net/JsonWebSocket.JsonNet.cs

I think your problem is here.
May 12, 2013 at 5:27 PM
Edited May 12, 2013 at 6:49 PM
Thanks it solved the problem, seems like I missed the fact you remove Newtonsoft.Json.dll to reduce size.