EsotericSoftware / kryonet

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

Unable to read object larger than read buffer: 1195725856 #163

Open Betalord opened 3 years ago

Betalord commented 3 years ago

Hi, checking my server's logs, I see a lot of exceptions of this type:

com.esotericsoftware.kryonet.KryoNetException: Unable to read object larger than read buffer: 1195725856 at com.esotericsoftware.kryonet.TcpConnection.readObject(TcpConnection.java:118) at com.esotericsoftware.kryonet.Server.update(Server.java:198) at com.betalord.sgx.network.ServerProcessor.run(ServerProcessor.java:90) at java.base/java.lang.Thread.run(Thread.java:834)

Now I use default constructor for server and for client, so the object buffer size is 2048 (default). I don't think I send any big objects over the network, they shouldn't be bigger than 1 KB I believe (but could be wrong). However, 1 GB as in given example is just absurd, so there must be some kind of a bug in kryonet that's causing it. From the logs I see I get different values, for example:

369295616 1195725856 369295616 50331695 1195725856 369295616 1431520594 50331695 50331686 1195725856 50331695 50331695 50331695 1212498244 1195725856 and so on.

Any idea on what is going on?

Ry-DS commented 3 years ago

Using Log.TRACE() from minlog can help you debug and see what kind of object is causing this problem. My guess is that you have a circular dependency (A has B as a property, but B also has A as a property).