DeserializeObject exception

Jun 21, 2012 at 1:49 PM

Hi,

 I just move from version 5-6, but I start getting error when try to connect:

DeserializeObject exception

InnerException = {"Invalid cast from 'System.Int64' to 'ResponseCode'."}

ResponseCode define as:

public enum ResponseCode : int

{SUCCESS = 0,

ALREADYCONNECT,

INVALID_ARGUMENTS,

TIMEOUT,

UNKOWN_ERROR,

};

 

Any idea?

Coordinator
Jun 21, 2012 at 3:42 PM

Which client/version are you using?

Jun 21, 2012 at 4:32 PM

I download the last version WebSocket4Net v. 0.7.

I return back to 0.5 recompile and all return to be OK.

I always got problems when move try to upgrate, what wrong, I do the following:

1.Download Server last version, then compile.

2.Take the bin files from Net40 , put in my reference folder, the files in reference folder are:


.\System.Windows.Interactivity.dll

.\WebSocket4Net.dll              

.\SuperWebSocket\log4net.dll.\

SuperWebSocket\Newtonsoft.Json.dll

.\SuperWebSocket\SuperSocket.Common.dll

.\SuperWebSocket\SuperSocket.SocketBase.dll

.\SuperWebSocket\SuperSocket.SocketEngine.dll

.\SuperWebSocket\SuperWebSocket.dll

2.Take (WebSocket4Net after compile) the bin files from Net40 , put in my reference folder.

Now recompile all project.

Anything missed? 

Coordinator
Jun 21, 2012 at 4:38 PM

So, after you roll back to old websocket4net, it works fine?

If so, te problem is of WebSocket4Net instead of SuperWebSocket, WebSocke4Net changed it's JSON library for smaller assembly size. You also can use JSON.NET back, you can find the two methods of SerializeObject and DeserializeObject of JsonWebSocket class are marked as virtual, so you can create a sub class to override these two mehods to use JSON to serialize and deserialize.

Jun 21, 2012 at 5:22 PM

thanks Kerry,

So you say, I can keep using old WebSocke4Net ?BTW I also got in error in old command Disconnect:

 

public class DISC : SubCommandBase{public override void ExecuteCommand(WebSocketServerSession session, StringCommandInfo commandInfo){session.Close();}}}

If fixed it to:

public class DISC : JsonSubCommand{protected override void ExecuteJsonCommand(WebSocketServerSession session, DisconnectRequest commandInfo){session.Close();}}


Any comment on that?

Jun 21, 2012 at 5:22 PM

 

thanks Kerry,

So you say, I can keep using old WebSocke4Net ?BTW I also got in error in old command Disconnect:

 

public class DISC : SubCommandBase{public override void ExecuteCommand(WebSocketServerSession session, StringCommandInfo commandInfo){session.Close();}}}

If fixed it to:

public class DISC : JsonSubCommand{protected override void ExecuteJsonCommand(WebSocketServerSession session, DisconnectRequest commandInfo){session.Close();}}


Any comment on that?

Coordinator
Jun 21, 2012 at 5:28 PM

According release note of SuperWebSocket 0.6,

http://superwebsocket.codeplex.com/releases/view/86249

* improved JSON sub protocol implementation (it broke the compatibility with JsonWebSocket in WebSocket4Net 0.5)

So the latest version SuperWebSocket cannot work well with WebSocket4Net 0.5, especially if you are using JsonWebSocket. 

Jun 21, 2012 at 5:45 PM

So I did all correct, toke last SuperWebsocket, And the only thing is that I should take WebSocket4Net 0.6 instead of 0.7 ?

Coordinator
Jun 21, 2012 at 5:57 PM

0.7