EsotericSoftware / kryonet

TCP/UDP client/server library for Java, based on Kryo
BSD 3-Clause "New" or "Revised" License
1.82k stars 419 forks source link

After sending TCP data to server client disconnects #50

Closed william-reed closed 10 years ago

william-reed commented 10 years ago

After creating a server and connecting a client things work fine. If I set client.setKeepAliveTCP(100); I can see from the server that these messsages are repeatidly being recieved by the server. But as soon as I use sendTCP(object) the client disconects

Pyeroh commented 9 years ago

In case anyone meet this issue (as I did) try using debug jars instead of production jars, set log level to (at least) debug, and make sure every instance that should be sent on the network have a constructor without parameters.

liketechnik commented 4 years ago

I know this is closed for more than 4 years, but it wasn't documented in a way that you don't try to send classes without constructors, because you don't know they have to have such a constructor.

Because this cost me almost 2 hours to track down, I kindly request to document this a lot more verbosely. (And thanks to @Pyeroh for the hint)

crykn commented 4 years ago

@liketechnik This is not an issue with KryoNet per se, but rather the Kryo serialisation. The version used of Kryo (2.24) doesn't show a corresponding error message when a constructor is missing. This is fixed in later versions. So to prevent this issue, either don't use the Kryo serialisation (which kinda defeats the purpose) or just use a more up to date version of Kryo with KryoNet.