Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.esotericsoftware.kryonet.KryoNetException: Incorrect number of bytes (1 remaining) used to deserialize object: com.esotericsoftware.kryonet.FrameworkMessage$KeepAlive@3fe26bec #80

Open
andyli386 opened this issue Dec 9, 2014 · 1 comment

Comments

@andyli386
Copy link

I'm a newbie with kryonet. I want to use kryonet in my libgdx game. When Server and Client run on desktop, they run well. But when server on desktop and client on Android, they got errors like this:

12-10 01:13:56.590    5082-5082/com.mygdx.game.android I/art﹕ Late-enabling -Xcheck:jni
12-10 01:13:56.761    5082-5082/com.mygdx.game.android I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:410>: QUALCOMM Build: 10/28/14, c33033c, Ia6306ec328
12-10 01:13:56.798    5082-5082/com.mygdx.game.android I/AndroidInput﹕ sensor listener setup
12-10 01:13:56.819    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 0: int (com.esotericsoftware.kryo.serializers.DefaultSerializers$IntSerializer)
12-10 01:13:56.819    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 1: String (com.esotericsoftware.kryo.serializers.DefaultSerializers$StringSerializer)
12-10 01:13:56.819    5082-5108/com.mygdx.game.android D/OpenGLRenderer﹕ Render dirty regions requested: true
12-10 01:13:56.820    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 2: float (com.esotericsoftware.kryo.serializers.DefaultSerializers$FloatSerializer)
12-10 01:13:56.820    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 3: boolean (com.esotericsoftware.kryo.serializers.DefaultSerializers$BooleanSerializer)
12-10 01:13:56.820    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 4: byte (com.esotericsoftware.kryo.serializers.DefaultSerializers$ByteSerializer)
12-10 01:13:56.820    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 5: char (com.esotericsoftware.kryo.serializers.DefaultSerializers$CharSerializer)
12-10 01:13:56.821    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 6: short (com.esotericsoftware.kryo.serializers.DefaultSerializers$ShortSerializer)
12-10 01:13:56.821    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 7: long (com.esotericsoftware.kryo.serializers.DefaultSerializers$LongSerializer)
12-10 01:13:56.821    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 8: double (com.esotericsoftware.kryo.serializers.DefaultSerializers$DoubleSerializer)
12-10 01:13:56.821    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 9: void (com.esotericsoftware.kryo.serializers.DefaultSerializers$VoidSerializer)
12-10 01:13:56.827    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: Serialization of Java8 lambdas is not available on this system.
12-10 01:13:56.828    5082-5082/com.mygdx.game.android D/Atlas﹕ Validating map...
12-10 01:13:56.828    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Running on Android platform. Use of sun.misc.Unsafe should be disabled
12-10 01:13:56.829    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Optimize ints: true
12-10 01:13:56.830    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] sun.misc.Unsafe is unavailable, using ASM.
12-10 01:13:56.837    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Field connectionID: int
12-10 01:13:56.838    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Field generics: null
12-10 01:13:56.838    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 10: com.esotericsoftware.kryonet.FrameworkMessage$RegisterTCP (com.esotericsoftware.kryo.serializers.FieldSerializer)
12-10 01:13:56.842    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Optimize ints: true
12-10 01:13:56.843    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] sun.misc.Unsafe is unavailable, using ASM.
12-10 01:13:56.843    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Field connectionID: int
12-10 01:13:56.843    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Field generics: null
12-10 01:13:56.843    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 11: com.esotericsoftware.kryonet.FrameworkMessage$RegisterUDP (com.esotericsoftware.kryo.serializers.FieldSerializer)
12-10 01:13:56.844    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Optimize ints: true
12-10 01:13:56.844    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] sun.misc.Unsafe is unavailable, using ASM.
12-10 01:13:56.844    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 12: com.esotericsoftware.kryonet.FrameworkMessage$KeepAlive (com.esotericsoftware.kryo.serializers.FieldSerializer)
12-10 01:13:56.844    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Optimize ints: true
12-10 01:13:56.844    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] sun.misc.Unsafe is unavailable, using ASM.
12-10 01:13:56.845    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 13: com.esotericsoftware.kryonet.FrameworkMessage$DiscoverHost (com.esotericsoftware.kryo.serializers.FieldSerializer)
12-10 01:13:56.845    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Optimize ints: true
12-10 01:13:56.845    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] sun.misc.Unsafe is unavailable, using ASM.
12-10 01:13:56.845    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Field id: int
12-10 01:13:56.845    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Field generics: null
12-10 01:13:56.846    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Field isReply: boolean
12-10 01:13:56.846    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Field generics: null
12-10 01:13:56.846    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 14: com.esotericsoftware.kryonet.FrameworkMessage$Ping (com.esotericsoftware.kryo.serializers.FieldSerializer)
12-10 01:13:56.850    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] References: false
12-10 01:13:56.850    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Registration required: true
12-10 01:13:56.856    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 15: com.mygdx.game.SomeRequest (com.esotericsoftware.kryo.serializers.JavaSerializer)
12-10 01:13:56.857    5082-5110/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryonet] Client thread started.
12-10 01:13:56.860    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Register class ID 16: com.mygdx.game.SomeResponse (com.esotericsoftware.kryo.serializers.JavaSerializer)
12-10 01:13:56.861    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00  INFO: [kryonet] Connecting: /192.168.0.2:54555/54777
12-10 01:13:56.865    5082-5108/com.mygdx.game.android I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:410>: QUALCOMM Build: 10/28/14, c33033c, Ia6306ec328
12-10 01:13:56.865    5082-5108/com.mygdx.game.android I/OpenGLRenderer﹕ Initialized EGL, version 1.4
12-10 01:13:56.872    5082-5106/com.mygdx.game.android I/System.out﹕ 00:00 DEBUG: [kryonet] Port 56856/TCP connected to: /192.168.0.2:54555
12-10 01:13:56.880    5082-5110/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Read class 12: com.esotericsoftware.kryonet.FrameworkMessage$KeepAlive
12-10 01:13:56.884    5082-5108/com.mygdx.game.android D/OpenGLRenderer﹕ Enabling debug mode 0
12-10 01:13:56.886    5082-5110/com.mygdx.game.android I/System.out﹕ 00:00 DEBUG: [kryo] Read: com.esotericsoftware.kryonet.FrameworkMessage$KeepAlive
12-10 01:13:56.889    5082-5110/com.mygdx.game.android I/System.out﹕ 00:00 TRACE: [kryo] Object graph complete.
12-10 01:13:56.891    5082-5110/com.mygdx.game.android I/System.out﹕ 00:00 ERROR: [kryonet] Error updating connection.
12-10 01:13:56.891    5082-5110/com.mygdx.game.android I/System.out﹕ com.esotericsoftware.kryonet.KryoNetException: Incorrect number of bytes (1 remaining) used to deserialize object: com.esotericsoftware.kryonet.FrameworkMessage$KeepAlive@3fe26bec
12-10 01:13:56.891    5082-5110/com.mygdx.game.android I/System.out﹕ at com.esotericsoftware.kryonet.TcpConnection.readObject(TcpConnection.java:164)
12-10 01:13:56.891    5082-5110/com.mygdx.game.android I/System.out﹕ at com.esotericsoftware.kryonet.Client.update(Client.java:273)
12-10 01:13:56.891    5082-5110/com.mygdx.game.android I/System.out﹕ at com.esotericsoftware.kryonet.Client.run(Client.java:356)
12-10 01:13:56.891    5082-5110/com.mygdx.game.android I/System.out﹕ at java.lang.Thread.run(Thread.java:818)
12-10 01:13:56.892    5082-5110/com.mygdx.game.android E/AndroidRuntime﹕ FATAL EXCEPTION: Client
    Process: com.mygdx.game.android, PID: 5082
    com.esotericsoftware.kryonet.KryoNetException: Incorrect number of bytes (1 remaining) used to deserialize object: com.esotericsoftware.kryonet.FrameworkMessage$KeepAlive@3fe26bec
            at com.esotericsoftware.kryonet.TcpConnection.readObject(TcpConnection.java:164)
            at com.esotericsoftware.kryonet.Client.update(Client.java:273)
            at com.esotericsoftware.kryonet.Client.run(Client.java:356)
            at java.lang.Thread.run(Thread.java:818)

This is main code of Server:

            Log.set(Log.LEVEL_TRACE);
            Server server = new Server();
            server.start();
            Kryo kryo = server.getKryo();
            kryo.register(SomeRequest.class, new JavaSerializer());
            kryo.register(SomeResponse.class, new JavaSerializer());

            try {
                server.bind(54555, 54777);
            } catch (Exception e) {
                e.printStackTrace();
            }


            server.addListener(new Listener() {
                public void received(Connection connection, Object object) {
                    if (object instanceof SomeRequest) {
                        SomeRequest request = (SomeRequest) object;
                        System.out.println(request.text + " In Server");
                        System.out.println("----->>>>>");
                        SomeResponse response = new SomeResponse();
                        response.text = "Thanks";
                        connection.sendTCP(response);
                        System.out.println("<<<<<-----");
                    }
                }
            });

This is main code of client:

            Log.set(Log.LEVEL_TRACE);

            final Client client = new Client();
            client.start();
            Kryo kryo = client.getKryo();
            kryo.register(SomeRequest.class, new JavaSerializer());
            kryo.register(SomeResponse.class, new JavaSerializer());

            final String IP = "192.168.0.2";// null;
            try {
                client.connect(5000, IP, 54555, 54777);
            } catch (Exception e) {
                System.out.println("connect ERROR!");
                e.printStackTrace();
            }
            SomeRequest someRequest = new SomeRequest();
            someRequest.text="Hello";
            client.sendTCP(someRequest);

            client.addListener(new Listener() {
                public void received (Connection connection, Object object) {
                    if (object instanceof SomeResponse) {
                        SomeResponse response = (SomeResponse)object;
                        System.out.println(response.text);
                    }
                }
            });

Anyone can help me? I'm sorry to bother.

@andyli386
Copy link
Author

It's mybe because of the JDK version. I install the Client and Server both on Android, they run well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant