简体   繁体   中英

Kryonet - buffer overflow - small object sending

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?

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

while (true) {

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM