Serialization issues

I’m trying to get a basic multiplayer type of system working. When the player joins a server, it sends the server it’s username, level, etc. and when the server receives it, it checks for things like if the player is banned, or if a player of the same name is already joined. If all the conditions return false, it sends a confirm message and the player is allowed to finalize the connection and join the game.

Problem is, the username/level etc. message fails to deserialize. I already called Serializer.registerClasses(Classes…); and this class is included. I double checked, it’s on both the client and server serialization methods. Here’s the stack trace I get:

Jan 18, 2013 9:38:05 PM reportError
SEVERE: Unhandled error, endpoint:NioEndpoint[1, java.nio.channels.SocketChannel[connected local=/ remote=/]], context:Envelope[NioEndpoint[1, java.nio.channels.SocketChannel[connected local=/ remote=/]], reliable, 21]
java.lang.RuntimeException: Error deserializing object
Caused by: Class not found for buffer data.
… 3 more

I’ve tried everything I can think of. It doesn’t even get into the message reading method. I’m pretty confused. Any help is appreciated.

That error indicates that the class was only registered on one end of the connection. This is why we recommend putting all serializer class registration into static utility methods called by both client and server so that it can never be screwed up.

The list and its order must be identical on both ends.


Ooooh. That explains it. I did register it but the order was different on both ends. Thanks a lot!

@pspeed I’m having another problem. When I host a server on Computer 1, then run another instance of the game on Computer 1, I can successfully join and it works perfectly. However, if I host on Computer 1, then open the game and join on Computer 2, something odd happens. Everything that should happen works up until getting the server to detect that the player has joined and send the confirmation message. What’s strange is, the connectionAdded method isn’t called at all, but if I close the server, the client on Computer 2 gets an error saying “Connection reset” as if it’s already connected. The server doesn’t report having any connections. I’m using Hamachi to network the 2 computers, if that changes anything.

It sounds like UDP packets aren’t getting through. If you don’t want to use UDP packets then you need to pass the proper arguments in to turn that off or the server will wait until it receives a UDP packet from the client before fully connecting.

If you turn up logging for the networking stuff then I think it logs some of this but I can’t remember for sure.

1 Like

Alright, I’ll look into it. Thanks again!

I’m basically clueless, but been working on multiplayer recently, so just going to air some thoughts in case they help… sorry if it’s a waste of your time haha:

  • for registering, I use the Util class from ZoneMonkey. Copy paste, choose what registering you want and you are up and running. Huge thx to normen for ZoneMonkey… really, really plenty good info in there to get started in multiplayer.
  • connectionAdded wasn’t called for me either at start, with no error message (which is normal) because I forgot to make the clientListener listen to that type of message. You did say it works on the same computer… just in case you forgot to update the code on the other computer for that, because your symptoms seem to point that way (I’m sure you did update the other computer code too, but just in case).
  • hamachi: I’ve had plenty programs refusing to connect correctly through hamachi. Works nearly always since I’ve been using ForceBindIP ( It’s freeware. Don’t think it’s open source though.

@loopies thanks, that actually does help some. I’ll check out ZoneMonkey and ForceBindIP. I did update the code on both computers, because I had them mapped via Hamachi, and I just did a build and moved it to the other computer, ran the code, changed the code, rinse and repeat.

Trying doing your game without UDP and see if that works. If you create the client and server requiring UDP then the connection isn’t “connected” until it sees both TCP and UDP packets.

@pspeed How would I disable the UDP? Should I just change the server and client initialization lines to not have a specified UDP port? Or would that just cause it to use a default port, or the same as the TCP port? I’m really inexperienced with the inner workings of Multiplayer.

Edit: I just tested it with a friend, and it’s working now. I guess it was just the other computer I tried to use. Now to get to work on some movement synchronization code! :smiley:,%20int,%20int,%20int),%20int,%20java.lang.String,%20int,%20int)