Android game with server / client not working using kryonet

I have been trying for several days to figure out what is wrong, changing things, etc., is useless.

Get the following error in Android studio when trying to debug the client part using a Samsung device:

com.esotericsoftware.kryonet.KryoNetException: Incorrect number of bytes (1 remaining) used to deserialize object: null
        at com.esotericsoftware.kryonet.TcpConnection.readObject(TcpConnection.java:146)
        at com.esotericsoftware.kryonet.Client.update(Client.java:255)
        at com.esotericsoftware.kryonet.Client.run(Client.java:338)
        at java.lang.Thread.run(Thread.java:856)

I think it uses the same version of java, and I will definitely register the class. Client side:

     Client client = new Client();
            Kryo kryo = client.getKryo();
            kryo.register(SomeRequest.class);
            kryo.register(SomeResponse.class);
            client.start();
            try{
                client.connect(5000, "10.0.0.4", 31055, 32055);
            }catch (IOException e) {
                throw new GdxRuntimeException(e);
            }

            SomeRequest request = new SomeRequest();
            request.text = "Here is the request";
            client.sendTCP(request);

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

Server side:

Server server = new Server();
        Kryo kryo = server.getKryo();
        kryo.register(SomeRequest.class);
        kryo.register(SomeResponse.class);
        server.start();
        System.out.println("server started");
        server.bind(31055, 32055);
        server.addListener(new Listener(){
            public void connected(Connection connection){
                System.out.println("connect");
            }

               public void received (Connection connection, Object object) {
                   if (object instanceof SomeRequest) {
                      SomeRequest request = (SomeRequest)object;
                      System.out.println(request.text);

                      SomeResponse response = new SomeResponse();
                      response.text = "Thanks";
                      connection.sendTCP(response);
                   }
                }
        });

    }

classes:

class SomeRequest{
    public String text;
}
class SomeResponse {
    public String text;
}

As you can see its very simple code, but connecting is a nightmare. Please help !! I create the client side in android studio and im creates the server in eclipse. Could this be causing problems? This is the only logical reason that I was able to get pregnant. How can i solve this?

+4
1

, .

  • / KryoNet.
  • Java.
  • IDE.

Eclipse, , Java- Android Studio, . , Gradle , KryoNet , Eclipse.

IRG LibGDX, . , ( ). , , , . .

, Java-, Android, , KryoNet, Gradle, , . , Android Studio Java .

+2

All Articles