3

Hiho. Everything was running without problems on localhost. Now the server is set on a professional host. The error is always the same:

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

The code is simple:

  String host = ui.inputHost();
    try {
        client.connect(5000, host, Network.port);
        // Server communication after connection can go here, or in Listener#connected().
    } catch (IOException ex) {
        ex.printStackTrace();
    }

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

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

The TestPacket class is just with a single string. When I connect via emulator everything works fine. When I open it on Samsung Galaxy S4 it throws this exception.

Already tried with increasing the buffer in Server's and Client's constructors - didn't work.

Any ideas?

1 Answers1

1

I don't know how is this possible - maybe someone could explain - but sleeping the thread for 1ms worked O.o

while (true) {

        test.msg = "55555444444444444444444444444444444444444444444444444444444444444455";
        client.sendTCP(test);
        synchronized (client) {
            try {
                client.wait(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
  • Presumably the extra time gives the client chance to read the data and thus remove it from the buffer? – Steve Smith Mar 09 '18 at 09:23
  • I don't know in your case, but this 'technique' allowed to point out a NullPointerException underneath, which I corrected and did not needed to wait in definitive code – Gregzenegair Jul 22 '19 at 15:48