Kryonet client doesn't even connect

234 views
Skip to first unread message

streetkin...@gmail.com

unread,
Oct 19, 2014, 6:01:08 AM10/19/14
to kryone...@googlegroups.com
Hi, I am trying to make a multiplayer game, client and android application made using android studio and libgdx. The server I create in Eclipse and will be hosted on digital ocean. 
But when I try to get even the most basic setup going, nothing works!! 
Error:
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 register the class exactly the same. 
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 I have on both sides:

class SomeRequest{
    public String text;
}
class SomeResponse {
    public String text;
}
As you can see its very basic code, but to connect is a nightmare. Please help!
All examples I've tried gives the same error. Literally copy and paste and still errors. 
Is there a problem using android studio and Eclipse, for client and server?

PLEASE help. Been struggling for days






James Hooker

unread,
Oct 19, 2014, 6:49:33 AM10/19/14
to kryone...@googlegroups.com
Out of curiosity, are you using the same version of Kryonet on both server and client side? Silly question, I know, but I had to ask..

--
You received this message because you are subscribed to the "kryonet-users" group.
http://groups.google.com/group/kryonet-users
---
You received this message because you are subscribed to the Google Groups "kryonet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kryonet-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

streetkin...@gmail.com

unread,
Oct 19, 2014, 7:08:08 AM10/19/14
to kryone...@googlegroups.com
Hi, Seidr thanks for reply. 

I've double checked, I do use the same. Kryonet 2.21-all

streetkin...@gmail.com

unread,
Oct 19, 2014, 7:13:47 AM10/19/14
to kryone...@googlegroups.com


Though when I look in the core it shows 2.22.0-RC1. 

PaulRuss

unread,
Oct 21, 2014, 9:31:24 AM10/21/14
to kryone...@googlegroups.com
Try adding a serializer to your code:

  kryo.register(Your.class, new JavaSerializer());

I've not time to try your code, but that might help.
Reply all
Reply to author
Forward
0 new messages