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

Oversized buffer #107

Open ghost opened 9 years ago

ghost commented 9 years ago

10-04 16:35:29.974 5730-5830/com.drkmns.gameloopballs E/AndroidRuntime: FATAL EXCEPTION: Thread-8160 10-04 16:35:29.974 5730-5830/com.drkmns.gameloopballs E/AndroidRuntime: Process: com.drkmns.gameloopballs, PID: 5730 10-04 16:35:29.974 5730-5830/com.drkmns.gameloopballs E/AndroidRuntime: com.esotericsoftware.kryo.KryoException: Buffer overflow. Available: 0, required: 9

So. I've tried everywhere - on Stackoverflow, on googlegroups - EVERYWHERE.

Tried with changing the buffer size in both server's and client's constructors. Tried with emulators, tablets and phones.

On localhost and android emulator everything is running well. When I put the server on a real machine this exception comes. (Also, it's not working on a Samsung Galaxy S4).

This is the first code which was not working:

name = "MOJANAZWA";
Login login = new Login();
login.name = name;
client.sendTCP(login);
TestPacket test = new TestPacket();
while (true) {

    test.msg = "33333333333333";
    client.sendTCP(test);
}

I've added this and it works (but I think it's a bad solution):

while (true) {

        test.msg = "55555444444444444444444444444444444444444444444444444444444444444455";
        client.sendTCP(test);
        synchronized (client) {
            try {
                client.wait(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

Is there someone that could help me?