Code Monkey home page Code Monkey logo

kryonet's Introduction

KryoNet

KryoNet can be downloaded on the releases page. Please use the KryoNet discussion group for support.

Overview

KryoNet is a Java library that provides a clean and simple API for efficient TCP and UDP client/server network communication using NIO. KryoNet uses the Kryo serialization library to automatically and efficiently transfer object graphs across the network.

KryoNet runs on both the desktop and on Android.

KryoNet is ideal for any client/server application. It is very efficient, so is especially good for games. KryoNet can also be useful for inter-process communication.

Running a server

This code starts a server on TCP port 54555 and UDP port 54777:

    Server server = new Server();
    server.start();
    server.bind(54555, 54777);

The start method starts a thread to handle incoming connections, reading/writing to the socket, and notifying listeners.

This code adds a listener to handle receiving objects:

    server.addListener(new Listener() {
       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);
          }
       }
    });

Note the Listener class has other notification methods that can be overridden.

Typically a listener has a series of instanceof checks to decide what to do with the object received. In this example, it prints out a string and sends a response over TCP.

The SomeRequest and SomeResponse classes are defined like this:

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

Kryo automatically serializes the objects to and from bytes.

Connecting a client

This code connects to a server running on TCP port 54555 and UDP port 54777:

    Client client = new Client();
    client.start();
    client.connect(5000, "192.168.0.4", 54555, 54777);
    
    SomeRequest request = new SomeRequest();
    request.text = "Here is the request";
    client.sendTCP(request);

The start method starts a thread to handle the outgoing connection, reading/writing to the socket, and notifying listeners. Note that the thread must be started before connect is called, else the outgoing connection will fail.

In this example, the connect method blocks for a maximum of 5000 milliseconds. If it times out or connecting otherwise fails, an exception is thrown (handling not shown). After the connection is made, the example sends a "SomeRequest" object to the server over TCP.

This code adds a listener to print out the response:

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

Registering classes

For the above examples to work, the classes that are going to be sent over the network must be registered with the following code:

    Kryo kryo = server.getKryo();
    kryo.register(SomeRequest.class);
    kryo.register(SomeResponse.class);
    Kryo kryo = client.getKryo();
    kryo.register(SomeRequest.class);
    kryo.register(SomeResponse.class);

This must be done on both the client and server, before any network communication occurs. It is very important that the exact same classes are registered on both the client and server, and that they are registered in the exact same order. Because of this, typically the code that registers classes is placed in a method on a class available to both the client and server.

Please see the Kryo serialization library for more information on how objects are serialized for network transfer. Kryo can serialize any object and supports data compression (eg, deflate compression).

TCP and UDP

KryoNet always uses a TCP port. This allows the framework to easily perform reliable communication and have a stateful connection. KryoNet can optionally use a UDP port in addition to the TCP port. While both ports can be used simultaneously, it is not recommended to send an huge amount of data on both at the same time because the two protocols can affect each other.

TCP is reliable, meaning objects sent are sure to arrive at their destination eventually. UDP is faster but unreliable, meaning an object sent may never be delivered. Because it is faster, UDP is typically used when many updates are being sent and it doesn't matter if an update is missed.

Note that KryoNet does not currently implement any extra features for UDP, such as reliability or flow control. It is left to the application to make proper use of the UDP connection.

Buffer sizes

KryoNet uses a few buffers for serialization and deserialization that must be sized appropriately for a specific application. See the Client and Server constructors for customizing the buffer sizes. There are two types of buffers, a write buffer and an object buffer.

To receive an object graph, the bytes are stored in the object buffer until all of the bytes for the object are received, then the object is deserialized. The object buffer should be sized at least as large as the largest object that will be received.

To send an object graph, it is serialized to the write buffer where it is queued until it can be written to the network socket. Typically it is written immediately, but when sending a lot of data or when the network is slow, it may remain queued in the write buffer for a short time. The write buffer should be sized at least as large as the largest object that will be sent, plus some head room to allow for some serialized objects to be queued. The amount of head room needed is dependent upon the size of objects being sent and how often they are sent.

To avoid very large buffer sizes, object graphs can be split into smaller pieces and sent separately. Collecting the pieces and reassembling the larger object graph, or writing them to disk, etc is left to the application code. If a large number of small object graphs are queued to be written at once, it may exceed the write buffer size. TcpIdleSender and InputStreamSender can be used to queue more data only when the connection is idle. Also see the setIdleThreshold method on the Connection class.

Threading

KryoNet imposes no restrictions on how threading is handled. The Server and Client classes have an update method that accepts connections and reads or writes any pending data for the current connections. The update method should be called periodically to process network events.

Both the Client and Server classes implement Runnable and the run method continually calls update until the stop method is called. Handing a client or server to a java.lang.Thread is a convenient way to have a dedicated update thread, and this is what the start method does. If this doesn't fit your needs, call update manually from the thread of your choice.

Listeners are notified from the update thread, so should not block for long. Static wrapper classes are provided on the Listener class to change how a listener is notified, such as ThreadedListener.

The update thread should never be blocked to wait for an incoming network message, as this will cause a deadlock.

LAN server discovery

KryoNet can broadcast a UDP message on the LAN to discover any servers running:

    InetAddress address = client.discoverHost(54777, 5000);
    System.out.println(address);

This will print the address of the first server found running on UDP port 54777. The call will block for up to 5000 milliseconds, waiting for a response.

Logging

KryoNet makes use of the low overhead, lightweight MinLog logging library. The logging level can be set in this way:

    Log.set(LEVEL_TRACE);

KryoNet does minimal logging at INFO and above levels. DEBUG is good to use during development and indicates the total number of bytes for each object sent. TRACE is good to use when debugging a specific problem, but outputs too much information to leave on all the time.

MinLog supports a fixed logging level, which will remove logging statements below that level. For efficiency, KryoNet can be compiled with a fixed logging level MinLog JAR. See MinLog for more information.

Pluggable Serialization

Serialization can be customized by providing a Serialization instance to the Client and Server constructors. By default KryoNet uses Kryo for serialization. Kryo uses a binary format and is very efficient, highly configurable, and does automatic serialization for most object graphs.

JsonSerialization is provided which uses JsonBeans to do serialization using JSON. JSON is human readable so is convenient for use during development to monitor the data being sent and received.

Remote Method Invocation

KryoNet has an easy to use mechanism for invoking methods on remote objects (RMI). This has a small amount of overhead versus explicitly sending objects. RMI can hide that methods are being marshaled and executed remotely, but in practice the code using such methods will need to be aware of the network communication to handle errors and methods that block. KryoNet's RMI is not related to the java.rmi package.

RMI is done by first calling registerClasses, creating an ObjectSpace and registering objects with an ID:

    ObjectSpace.registerClasses(endPoint.getKryo());
    ObjectSpace objectSpace = new ObjectSpace();
    objectSpace.register(42, someObject);
    // ...
    objectSpace.addConnection(connection);

Multiple ObjectSpaces can be created for both the client or server side. Once registered, objects can be used on the other side of the registered connections:

    SomeObject someObject = ObjectSpace.getRemoteObject(connection, 42, SomeObject.class);
    SomeResult result = someObject.doSomething();

The getRemoteObject method returns a proxy object that represents the specified class. When a method on the class is called, a message is sent over the connection and on the remote side the method is invoked on the registered object. The method blocks until the return value is sent back over the connection.

Exactly how the remote method invocation is performed can be customized by casting the proxy object to a RemoteObject.

    SomeObject someObject = ObjectSpace.getRemoteObject(connection, 42, SomeObject.class);
    ((RemoteObject)someObject).setNonBlocking(true, true);
    someObject.doSomething();

Note that the SomeObject class does not need to implement RemoteObject, this is handled automatically.

The first true passed to setNonBlocking causes remote method invocations to be non-blocking. When doSomething is invoked, it will not block and wait for the return value. Instead the method will just return null.

The second true passed to setNonBlocking indicates that the return value of remote method invocations are to be ignored. This means the server will not waste time or bandwidth sending the result of the remote method invocation.

If the second parameter for setNonBlocking is false, the server will send back the remote method invocation return value. There are two ways to access a return value for a non-blocking method invocation:

    RemoteObject remoteObject = (RemoteObject)someObject;
    remoteObject.setNonBlocking(true, false);
    someObject.doSomething();
    // ...
    SomeResult result = remoteObject.waitForLastResponse();

    RemoteObject remoteObject = (RemoteObject)someObject;
    remoteObject.setNonBlocking(true, false);
    someObject.doSomething();
    byte responseID = remoteObject.getLastResponseID();
    // ...
    SomeResult result = remoteObject.waitForResponse(responseID);

KryoNet versus ?

KryoNet makes the assumptions that it will only be used for client/server architectures and that KryoNet will be used on both sides of the network. Because KryoNet solves a specific problem, the KryoNet API can do so very elegantly.

The Apache MINA project is similar to KryoNet. MINA's API is lower level and a great deal more complicated. Even the simplest client/server will require a lot more code to be written. MINA also is not integrated with a robust serialization framework and doesn't intrinsically support RMI.

The PyroNet project is a minimal layer over NIO. It provides TCP networking similar to KryoNet, but without the higher level features. Priobit requires all network communication to occur on a single thread.

The Java Game Networking project is a higher level library similar to KryoNet. JGN does not have as simple of an API.

Maven Build

<repositories>
   <repository>
      <id>clojars</id>
      <url>http://clojars.org/repo/</url>
   </repository>
</repositories>

<dependencies>
   <dependency>
      <groupId>kryonet</groupId>
      <artifactId>kryonet</artifactId>
      <version>2.21</version>
   </dependency>
</dependencies>

Further reading

Beyond this documentation page, you may find the following links useful:

kryonet's People

Contributors

badlogic avatar codetaylor avatar ekeitho avatar georgeto avatar jrenner avatar magro avatar murray-andrew-r avatar nathansweet avatar sylvia43 avatar tudalex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kryonet's Issues

UDP debugging

Hi

I wrote a very simple utility to test my UDP communication in java. Browsing the web I found only theoretical simulators or a whole bunch of live linux cds which transform the whole host machine into an emulator.

Java Wan Emulator

Would you have any use for this?

Something that works in 2.12 doesn't work in 2..20

From [email protected] on July 26, 2013 14:05:05

What steps will reproduce the problem?

  1. I followed this simple tutorial at http://www.youtube.com/watch?v=1fLXEL4ngpE
  2. When i run the server, and then the client i get this message
    0:00 INFO: [kryonet] Server opened.
    00:00 TRACE: [kryonet] Server thread started.
    00:15 DEBUG: [kryonet] Port 54555/TCP connected to: /127.0.0.1:52642
    00:15 TRACE: [kryonet] Connection listener added: com.esotericsoftware.kryonet.Server$1
    00:15 TRACE: [kryo] Write class 9: com.esotericsoftware.kryonet.FrameworkMessage$RegisterTCP
    00:15 DEBUG: [kryo] Write: com.esotericsoftware.kryonet.FrameworkMessage$RegisterTCP
    00:15 TRACE: [kryo] Write field: connectionID (com.esotericsoftware.kryonet.FrameworkMessage$RegisterTCP)
    00:15 TRACE: [kryo] Write int: 1
    00:15 TRACE: [kryo] Object graph complete.
    00:15 TRACE: [kryonet] Connection 1 sent TCP: RegisterTCP (6)
    00:15 INFO: [kryonet] Connection 1 connected: /127.0.0.1
    00:15 INFO: [SERVER] Someone is trying to connect.
    00:15 TRACE: [kryonet] Unable to read TCP from: Connection 1
    java.io.IOException: An existing connection was forcibly closed by the remote host
    at sun.nio.ch.SocketDispatcher.read0(Native Method)
    at sun.nio.ch.SocketDispatcher.read(Unknown Source)
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source)
    at sun.nio.ch.IOUtil.read(Unknown Source)
    at sun.nio.ch.SocketChannelImpl.read(Unknown Source)
    at com.esotericsoftware.kryonet.TcpConnection.readObject(TcpConnection.java:107)
    at com.esotericsoftware.kryonet.Server.update(Server.java:192)
    at com.esotericsoftware.kryonet.Server.run(Server.java:350)
    at java.lang.Thread.run(Unknown Source)
    00:15 INFO: [SERVER] Someone is trying to disconnect.
    00:15 INFO: [kryonet] Connection 1 disconnected.
  3. But when i change the library from 2.20 to 2.12
    Everything is fine. I dont need to change anything at all

    What is the expected output? What do you see instead?
    What you type in the client gets shown in the server

    What version of the product are you using? On what operating system?
    2.20, problem persist in 2.18 too

    Please provide any additional information below.
    I create a bitbucket repository so you didnt have to look through all the tutorial
    https://bitbucket.org/fjoseph/kryonet-error

Original issue: http://code.google.com/p/kryonet/issues/detail?id=36

Not able to find anyone when discovering hosts

From [email protected] on October 27, 2013 17:13:03

What steps will reproduce the problem?

  1. Code:
    Server server = new Server();
    server.start();
    server.bind(17771, 5000);

    Client client = new Client();
    List<InetAddress> addresses = client.discoverHosts(17771, 5000);
    System.out.print(addresses);
  2. Run Code on two Computers which are in the same network
  3. Both PCs are able to create, start and bind the servers (without any errors)
  4. Both PCs print [](Empty list). Also, when I press a refresh button (which executes
    "List<InetAddress> addresses = client.discoverHosts(17771, 5000);
    System.out.print(addresses);"
    after the Servers were created on both PCs) then I get a "[]" message again. No Hosts found...

    Help is appreciated :)





    What is the expected output? What do you see instead?


    What version of the product are you using? On what operating system?


    Please provide any additional information below.

Original issue: http://code.google.com/p/kryonet/issues/detail?id=44

Kryonet throws Bind Exception in server.bind()

From [email protected] on October 03, 2013 15:00:00

The code I used is as follows

try
{
Server server = new Server();
server.start();
server.bind(16384);
server.addListener(new Listener() {
public void received (Connection connection, Object object)
{
byte[] b = (byte[]) object;
System.out.println("Received Time: " + System.currentTimeMillis() + " " + b.length);
}
});

    }
    catch(Exception e)
    {
        throw e;
    }

Kryonet throws
Exception in thread "main" java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at com.esotericsoftware.kryonet.Server.bind(Server.java:133)
at com.esotericsoftware.kryonet.Server.bind(Server.java:117)
at KryoMain.deployServer(KryoMain.java:33)
at KryoMain.main(KryoMain.java:53)

Original issue: http://code.google.com/p/kryonet/issues/detail?id=40

Multiple Server connection

From [email protected] on June 13, 2012 01:53:34

What steps will reproduce the problem?

  1. Connect client to server1
  2. Connect client to server2
    3.

    What is the expected output? What do you see instead?
    Exception in thread "Client" java.lang.IllegalStateException: Cannot connect on the connection's update thread.

    What version of the product are you using? On what operating system?
    Netbeans, Win7

    Hi !
    I'm trying to connect my client to 2 server (1main and 1login), but the client cannot connect ! I tried by closing/stoping my server1 to connect to server2 but always same error...

Original issue: http://code.google.com/p/kryonet/issues/detail?id=22

TCP timeout when using 3g

From [email protected] on July 13, 2011 00:12:13

What steps will reproduce the problem?
1.connect the android phone client to a server with default tcp keep alive/timeout not changed
2. use wifi, you will see no disconnects
3. switch to 3g, and you'll see every 12 seconds there is a disconnect

What is the expected output? What do you see instead?
3g should not disconnect every 12 seconds, as my connection is just fine.

What version of the product are you using? On what operating system?
1.04

Please provide any additional information below.
Although the cellphone's 3g connection isn't as stable as wifi, it is pretty stable for all the programs I use. Definitely shouldn't be considered timing out every 12 seconds, as set in the client/server .setTimeout() method.

When using wifi for the client, it works perfectly...

Original issue: http://code.google.com/p/kryonet/issues/detail?id=10

Website's RMI Example is inconsistent with JavaDoc

From [email protected] on October 04, 2013 01:03:15

What steps will reproduce the problem?

  1. Visit the project website.
    https://code.google.com/p/kryonet/#Remote_Method_Invocation


    What is the expected output? What do you see instead?

    This is what is currently on the site.
    ~ ~ ~ ~
    SomeObject someObject = ObjectSpace.getRemoteObject(connection, 42, SomeObject.class);
    ((RemoteObject)someObject).setNonBlocking(true, true);
    someObject.doSomething();
    ~ ~ ~ ~
    This and the other RMI examples depict a setNonBlocking method with two boolean args.


    However according to the downloaded zip's javadoc, the RemoteObject class has two separate methods, each with a single boolean arg.
  • setNonBlocking( boolean nonBlocking )
  • setTransmitReturnValue( boolean transmit )

    I assume the javadoc is authoritative. I haven't tried out the library yet.


    What version of the product are you using?
    KryoNet 2.20

Original issue: http://code.google.com/p/kryonet/issues/detail?id=41

Discovery broken out of the box

From [email protected] on December 29, 2012 23:19:58

What steps will reproduce the problem?

  1. Download the latest .zip
  2. Using the all jar.
  3. Just run the discovery code copy pasted from the front page of this project. First run server, then run client. The client immediately throws an exception.

    What is the expected output? What do you see instead?
    This code should work out of the Box

    What version of the product are you using? On what operating system?
    Kronet 2.20
    Mac OSx 10.8

    Please provide any additional information below.
    Immediately get this error on the client.

    00:00 ERROR: [kryonet] Host discovery failed.
    java.io.IOException: Invalid argument
    at java.net.PlainDatagramSocketImpl.send(Native Method)
    at java.net.DatagramSocket.send(DatagramSocket.java:625)
    at com.esotericsoftware.kryonet.Client.broadcast(Client.java:412)
    at com.esotericsoftware.kryonet.Client.discoverHost(Client.java:428)
    at DiscoveryClient.main(DiscoveryClient.java:15)
    null

Original issue: http://code.google.com/p/kryonet/issues/detail?id=29

Incorrect locking code in Server.java

From [email protected] on May 31, 2011 05:41:44

in Server.update, the code block looks like this:

synchronized (updateLock) { // Blocks to avoid a select while the selector is used to bind the server connection.
}

if (timeout > 0) {
selector.select(timeout);
} else {
selector.selectNow();
}

That is an empty synchronized block.
It seems what you wanted was :

synchronized (updateLock) { // Blocks to avoid a select while the selector is used to bind the server connection.
if (timeout > 0) {
selector.select(timeout);
} else {
selector.selectNow();
}
}

Original issue: http://code.google.com/p/kryonet/issues/detail?id=8

Can't build trunk from source using scar

From [email protected] on May 08, 2013 11:32:43

After getting the following exception when attempting to use host discovery on OS X 10.6.8 (Snow Leopard):

00:31 ERROR: [kryonet] Host discovery failed.
java.io.IOException: Invalid argument
at java.net.PlainDatagramSocketImpl.send(Native Method)
at java.net.DatagramSocket.send(DatagramSocket.java:625)
at com.esotericsoftware.kryonet.Client.broadcast(Client.java:412)
at com.esotericsoftware.kryonet.Client.discoverHosts(Client.java:455)

I found out that this is supposedly fixed in the kryonet svn trunk (r132), by surrounding the send methods with try / catch blocks. But the latest release 2.20, does not have this fix. So the only option available at this time appears to be checkout out the latest source from the svn trunk and build it myself.

I finally figured out that I need to use Scar to build the library from source. So, I checkout the latest kryonet source (136) from the svn trunk, download the latest Scar release, cp scar and scar.jar into the kryonet source folder (directory containing project.yaml), and run ./scar. Here's what I get (highly edited for brevity):

Aaron:kryonet Aaron$ ./scar
00:01 INFO: [kryonet] Target: /Users/Aaron/NetBeansProjects/target/kryonet/
00:01 INFO: [kryonet] Clean
00:01 INFO: [kryonet] Compile
/Users/Aaron/NetBeansProjects/kryonet/src/com/esotericsoftware/kryonet/KryoSerialization.java:6: package com.esotericsoftware.kryo does not exist
import com.esotericsoftware.kryo.Kryo;
^
/Users/Aaron/NetBeansProjects/kryonet/src/com/esotericsoftware/kryonet/Connection.java:14: package com.esotericsoftware.minlog does not exist
import static com.esotericsoftware.minlog.Log.*;
^
/Users/Aaron/NetBeansProjects/kryonet/src/com/esotericsoftware/kryonet/JsonSerialization.java:7: package com.esotericsoftware.jsonbeans does not exist
import com.esotericsoftware.jsonbeans.Json;
^
/Users/Aaron/NetBeansProjects/kryonet/src/com/esotericsoftware/kryonet/Connection.java:61: cannot find symbol
symbol : method trace(java.lang.String,java.lang.String)
location: class com.esotericsoftware.kryonet.Connection
if (TRACE) trace("kryonet", this + " TCP had nothing to send.");
^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
100 errors
Exception in thread "main" java.lang.RuntimeException: Error executing code for project: kryonet
at com.esotericsoftware.scar.Build.executeDocument(Build.java:413)
at com.esotericsoftware.scar.Build.main(Build.java:433)
Caused by: java.lang.RuntimeException: Error executing code:
Build.build(project);
Build.oneJAR(project);
at com.esotericsoftware.scar.Scar.executeCode(Scar.java:1199)
at com.esotericsoftware.scar.Build.executeDocument(Build.java:411)
... 1 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.esotericsoftware.scar.Scar.executeCode(Scar.java:1197)
... 2 more
Caused by: java.lang.RuntimeException: Error during compilation.
Source: 17 files
Classpath: /Users/Aaron/NetBeansProjects/kryonet/lib/jsonbeans-0.5.jar, /Users/Aaron/NetBeansProjects/kryonet/lib/asm-4.0.jar, /Users/Aaron/NetBeansProjects/kryonet/lib/reflectasm-1.07.jar, /Users/Aaron/NetBeansProjects/kryonet/lib/minlog-1.2.jar, /Users/Aaron/NetBeansProjects/kryonet/lib/objenesis-1.2.jar, /Users/Aaron/NetBeansProjects/kryonet/lib/kryo-debug-2.20.jar
at com.esotericsoftware.scar.Scar.compile(Scar.java:1010)
at com.esotericsoftware.scar.Build.compile(Build.java:169)
at com.esotericsoftware.scar.Build.build(Build.java:391)
at Generated.execute(Generated.java from :10)
... 7 more

Obviously it's not finding the libraries in the lib folder, which doesn't make any sense. I read a post on kryonet-users saying that all you (Nate) had to do was go to the kryonet directory and type scar. I tried to add the relevant entries to project.yaml, but I'm getting the same output no matter what I do.

Can you please explain how to build kryonet from the latest source, using scar, without these errors? Thank you!

Also, when are you going to be releasing the next version of kryonet with this bugfix, rendering this entire process unnecessary?

Original issue: http://code.google.com/p/kryonet/issues/detail?id=33

When Binding both TCP and UDP, the listener doesn't run.

From [email protected] on December 24, 2010 04:39:40

What steps will reproduce the problem?

  1. Create a new server object. (Server server;)
  2. Add a listener to the server. (server.addListener(new Listener() {..})
  3. Bind the server to a random TCP and UDP port. (server.bind(1234, 1235);)
  4. Execute the server.
  5. Connect to the server using a client. The events within the listener don't fire.

    What is the expected output? What do you see instead?
    The server's listener events should fire. But instead, they don't.

    What version of the product are you using? On what operating system?
    I am using the newest version of kryonet on Linux, with NetBeans as the IDE.

    Please provide any additional information below.
    I noticed that it only works when TCP is binded. That is, instead of specifying 2 integers (TCP_PORT, UDP_PORT) and only specifying 1, for the TCP port, events will fire.

Original issue: http://code.google.com/p/kryonet/issues/detail?id=7

Error on special characters

From killgt on November 04, 2009 23:21:22

What steps will reproduce the problem?

  1. Make a String with some special character like String test = "รกรฉรญรณรบ"
  2. Send it.
  3. Server carsh

    What is the expected output? What do you see instead?
    The real string

    What version of the product are you using? On what operating system?
    0.92

    Please provide any additional information below.

    I think its a serialization problem...
    Great job with this lib... im currently using it for a little online game.
    Thank you :D

Original issue: http://code.google.com/p/kryonet/issues/detail?id=1

server select : 100&#37; cpu

From [email protected] on May 25, 2012 04:48:18

Problem similar to issue #17 but "selector.select(timeout);" does not return 0, so the sleep is not reached.

The thread loops until the next select in :
for(Iterator<SelectionKey> iter = keys.iterator(); iter.hasNext();) {
[...]
if (udp != null && fromConnection.udpRemoteAddress == null) continue;

Running KryoNet 2.09
java version "1.7.0_04"
GNU/Linux x86_64 Ubuntu 9.04

Original issue: http://code.google.com/p/kryonet/issues/detail?id=19

ConcurrentModificationException upon disconnect of 3 or more Client

From [email protected] on May 01, 2012 11:20:21

What steps will reproduce the problem?

  1. I guess, that some clients are disconnecting at the same time. (It always happens upon the end of our game, when the players disconnect. Requires 3 or more connected players.)

    What is the expected output? What do you see instead?
    No CME ;-)

    What version of the product are you using? On what operating system?
    kryonet_1.04
    Windows 7 x64 & OSX Lion
    Java7 (x64 & x32) & Java7u4 (x64 & x32)

    Please provide any additional information below.

    Exception in thread "ServerServiceContext" java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextEntry(HashMap.java:806)
    at java.util.HashMap$KeyIterator.next(HashMap.java:841)
    at com.esotericsoftware.kryonet.Server.update(Server.java:174)
    at com.esotericsoftware.kryonet.Server.run(Server.java:336)
    at ch.xxx.xxx.net.server.impl2.ServerServiceContext.run(ServerServiceContext.java:156)
    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$1.run(AbstractExecutionThreadService.java:52)
    at java.lang.Thread.run(Thread.java:722)

Original issue: http://code.google.com/p/kryonet/issues/detail?id=18

Listener.received sees FrameworkMessage.KeepAlive messages

From [email protected] on January 21, 2013 02:28:47

What steps will reproduce the problem?

  1. Create a client, add a listener with received(Connection connection, Object o) that logs o.getClass().toString()
  2. Connect to a server, stay idle
  3. See FrameworkMessage.KeepAlive messages

    What is the expected output? What do you see instead?
    I assume those messages should be considered internal to the framework and hidden to the API consumers.

    What version of the product are you using? On what operating system?
    http://kryonet.googlecode.com/svn/trunk@132

    Please provide any additional information below.
    Can be tested using the commit 6a8677496f018553c5ef2bceca3df63c4ed48a26 of https://github.com/pcarrier/kryoflood with 2+ clients, and
    removing the "else if (o instanceof FrameworkMessage.KeepAlive) {}" workaround.

Original issue: http://code.google.com/p/kryonet/issues/detail?id=31

Problem with reconnecting to server

From [email protected] on March 11, 2010 12:39:40

What steps will reproduce the problem?

  1. Create simple class for testing
    Client client = new Client(10000,10000);
    client.start();
    while (true){
    if(client.isConnected() == false){
    try {
    client.connect(5000, "5.65.32.105", 54555, 54777);
    } catch (IOException ex) {
    // host not found
    }
    }
    try {
    Thread.sleep(5000);
    } catch (InterruptedException ex) {
    // sleep interrupted
    }
    }
  2. Client program is trying to maintain connection to server
  3. close and start server

    What is the expected output? What do you see instead?
    expected result would be client reconnecting to server

    instead we get following exception:
    00:00 INFO: [kryonet] Connection 1 connected: /5.65.32.105
    00:03 INFO: [kryonet] Connection 1 disconnected.
    00:23 ERROR: [kryonet] Error updating connection.
    com.esotericsoftware.kryo.SerializationException: Invalid object length: 0
    Exception in thread "Client"
    com.esotericsoftware.kryo.SerializationException: Invalid object length: 0
    at
    com.esotericsoftware.kryonet.TcpConnection.readObject(TcpConnection.java:110)
    at com.esotericsoftware.kryonet.Client.update(Client.java:197)
    at com.esotericsoftware.kryonet.Client.run(Client.java:251)
    at java.lang.Thread.run(Thread.java:619)
    at
    com.esotericsoftware.kryonet.TcpConnection.readObject(TcpConnection.java:110)
    at com.esotericsoftware.kryonet.Client.update(Client.java:197)
    at com.esotericsoftware.kryonet.Client.run(Client.java:251)
    at java.lang.Thread.run(Thread.java:619)


    What version of the product are you using? On what operating system?
    0.93

    Please provide any additional information below.

Original issue: http://code.google.com/p/kryonet/issues/detail?id=2

Client Disconnects immediately

From [email protected] on February 22, 2013 21:08:37

What steps will reproduce the problem?
1.Create a server
2.Create a client
3.Client connects to server

I expect client to get connected and stay or continue that connection until a close operation is called. Instead Client gets connected initially but disconnects immediately


I m using Kryonet 2.12 on Windows 7.


Please provide any additional information below.

Original issue: http://code.google.com/p/kryonet/issues/detail?id=32

How to use the BlowfishSerializer

From [email protected] on June 19, 2012 10:53:21

Could you provide some guidance on how to implement it. I'm currently doing the following:

kryo.register(JSONObject.class, new BlowfishCompressor(kryo.newSerializer(JSONObject.class), key, WRITE_BUFFER_SIZE));
kryo.register(String[].class, new BlowfishCompressor(kryo.newSerializer(String[].class), key, WRITE_BUFFER_SIZE));

However, the newest version has changed - it's now BlowfishSerializer and also the way to register classes has changed. Anyhow, I may not have done it correctly before either. What's your advice on how to implement it? Is there some way to add it as a default serializer for all objects.

What version of the product are you using? On what operating system?
Currently 1.04 (above code). Would like to upgrade to the latest version.

Please provide any additional information below.
Thanks for an awesome product!

Original issue: http://code.google.com/p/kryonet/issues/detail?id=23

using interfaces in communication

From [email protected] on September 15, 2012 20:39:30

What steps will reproduce the problem?

  1. I created a interface say 'A' which is implemented by 'B' and 'C'
  2. I want to send 'B' or 'C' from client and without knowing server will forword them to other client.
  3. So I am accepting them at server side as 'A'
  4. If i register 'A' it gives error that 'A' does not have default constructor.
  5. If i do not register 'A' then it gives error that class 'A' not registered

    What version of the product are you using? On what operating system?
    kryonet 2.18 , redhat

    Please provide any additional information below.

    Really nice product !! :)

Original issue: http://code.google.com/p/kryonet/issues/detail?id=25

Server disconnecting when sending a lot of data in small chunks

From [email protected] on July 20, 2013 15:43:14

Hello,

I am experiencing problems sending a lot of chunks of small amounts of data from my android phone to my computer.

What I am trying to achieve is sending the preview images from the camera to my computer, of which the smallest setting is an image of 176*144, which gives 38016 bytes of data, stored in an array. First I had buffer overflows, so I split it up into parts of 512, 1024 or2048 bytes (I tried different settings), after also increasing the buffers up to 65536 bytes, for both the server and client (my computer is the server, my phone is the client).

The errors I am achieving are broken either SocketExceptions: Broken pipe or Connection is closed error. If I am correct, this indicates that my computer closes the connection while my phone still tries to send data. I have absolutely no clue why this happens, since I am not getting any errors on my computer (or any other messages for that matter, which is strange, considering I set the log level on LEVEL_TRACE, which did work on my phone).
It might send the first chunk successfully and fail at the second. Or it might get to the 4th chunk. I never seem to receive anything on my computer though (according to my own output there).
However, when I spam String-messages instead of chunks, that does work just fine and those get received.

I also tried sending only every 100th image (unacceptable, but it was just to try and test the concept of breaking up the images in smaller parts would work), but that didn't work either.

In short:

  • Sending images from my phone (client) to my computer (server), of about 38kb in size per image, or in smaller chunks per image of 512, 1024 or 2048 bytes, seems to make my computer break the connection.
  • The computer never seems to receive any chunk at all.
  • Sending strings instead of my own chunks does work.

I attached error reports from my phone (none from my computer since there aren't any messages coming out there).

Any suggestions would be appreciated. (I thought of making my phone the server, but didn't think it would matter much. Also, I might want to connect multiple phones to my computer, meaning I would have to initialise multiple clients. If it would solve my problems, I would though)

Attachment: error.txt error2.txt

Original issue: http://code.google.com/p/kryonet/issues/detail?id=35

Moving connections from class to class

From [email protected] on November 04, 2012 17:39:15

What steps will reproduce the problem?

  1. client login to mainServer
  2. the mainServer has a Game class that use server protocol
  3. how do i input client(connection) to the new server, with out
    making them connect 2 servers.

    What is the expected output? What do you see instead?
    how do i move clients, from main Server, to sub Server.

    What version of the product are you using? On what operating system?
    2.2

    Please provide any additional information below.

Original issue: http://code.google.com/p/kryonet/issues/detail?id=26

Kryo serialization class order is wrong in 2.21

From my client I get the following trace output:
00:00 TRACE: [kryo] Register class ID 0: int (com.esotericsoftware.kryo.serializers.DefaultSerializers$IntSerializer)
00:00 TRACE: [kryo] Register class ID 1: String (com.esotericsoftware.kryo.serializers.DefaultSerializers$StringSerializer)
00:00 TRACE: [kryo] Register class ID 2: float (com.esotericsoftware.kryo.serializers.DefaultSerializers$FloatSerializer)
00:00 TRACE: [kryo] Register class ID 3: boolean (com.esotericsoftware.kryo.serializers.DefaultSerializers$BooleanSerializer)
00:00 TRACE: [kryo] Register class ID 4: byte (com.esotericsoftware.kryo.serializers.DefaultSerializers$ByteSerializer)
00:00 TRACE: [kryo] Register class ID 5: char (com.esotericsoftware.kryo.serializers.DefaultSerializers$CharSerializer)
00:00 TRACE: [kryo] Register class ID 6: short (com.esotericsoftware.kryo.serializers.DefaultSerializers$ShortSerializer)
00:00 TRACE: [kryo] Register class ID 7: long (com.esotericsoftware.kryo.serializers.DefaultSerializers$LongSerializer)
00:00 TRACE: [kryo] Register class ID 8: double (com.esotericsoftware.kryo.serializers.DefaultSerializers$DoubleSerializer)
00:00 TRACE: [kryo] Register class ID 9: void (com.esotericsoftware.kryo.serializers.DefaultSerializers$VoidSerializer)
00:00 TRACE: [kryo] Register class ID 10: com.esotericsoftware.kryonet.FrameworkMessage$RegisterTCP (com.esotericsoftware.kryo.serializers.FieldSerializer)

However on the server I have:

00:00 TRACE: [kryo] Register class ID 0: int (com.esotericsoftware.kryo.serializers.DefaultSerializers$IntSerializer)
00:00 TRACE: [kryo] Register class ID 1: String (com.esotericsoftware.kryo.serializers.DefaultSerializers$StringSerializer)
00:00 TRACE: [kryo] Register class ID 2: float (com.esotericsoftware.kryo.serializers.DefaultSerializers$FloatSerializer)
00:00 TRACE: [kryo] Register class ID 3: boolean (com.esotericsoftware.kryo.serializers.DefaultSerializers$BooleanSerializer)
00:00 TRACE: [kryo] Register class ID 4: byte (com.esotericsoftware.kryo.serializers.DefaultSerializers$ByteSerializer)
00:00 TRACE: [kryo] Register class ID 5: char (com.esotericsoftware.kryo.serializers.DefaultSerializers$CharSerializer)
00:00 TRACE: [kryo] Register class ID 6: short (com.esotericsoftware.kryo.serializers.DefaultSerializers$ShortSerializer)
00:00 TRACE: [kryo] Register class ID 7: long (com.esotericsoftware.kryo.serializers.DefaultSerializers$LongSerializer)
00:00 TRACE: [kryo] Register class ID 8: double (com.esotericsoftware.kryo.serializers.DefaultSerializers$DoubleSerializer)
00:00 TRACE: [kryo] Register class ID 9: com.esotericsoftware.kryonet.FrameworkMessage$RegisterTCP (com.esotericsoftware.kryo.serializers.FieldSerializer)

Which means that when trying to do the tcp registration everything fails as the client tries to use the void serialiser. I'm using version 2.21 and the all-in-one jar.

Make the fields in Client and Server protected instead of private

From [email protected] on December 28, 2011 19:21:12

All class fields in both Client and Server classes are private, which prevents the classes to be extended in many ways. For example I need to determine whether a given server is started or not. I can't, there is no isConnected() method in the Server.

So I thought, no problem, I'll just extend it. Can't either. All fields are private, so I can't access the shutdown field which tracks exactly that in the Server class.

Instead of private, all fields should be protected so developers can tweak things without messing around with the original source code (which gets replaced when a new version comes out). :)

Thanks!
Eduardo

Original issue: http://code.google.com/p/kryonet/issues/detail?id=15

Server.update() consumes 100&#37; CPU resources

From [email protected] on March 10, 2012 16:44:32

I have noticed that kryonet server is consuming too much CPU time.

When my app is running on my local Tomcat in Windows environment everything is working fine. But after being deployed to a production server which is Debian based it starts to load CPU at 100% even with few users connected. I can see in profiler that kryonet thread called "Server" consumes almost 100% CPU time with executing Server.update() method.

I have found that a lot of NIO-based network libraries had a similar issue due broken NIO Selector implementation on Linux. But I use the latest jdk in wich I suppose this bug should be already fixed.

So is any workarounds to avoid such high CPU load?

Server environment:

uname -a:
Linux 2.6.32.46-xenU #1 SMP Thu Oct 27 23:15:48 UTC 2011 i686 GNU/Linux

java -version:
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode)

Attachment: cpu_samples.png cpu_thread_time.png thread_dump_server.txt

Original issue: http://code.google.com/p/kryonet/issues/detail?id=17

Typo in lag listener?

From [email protected] on June 04, 2011 19:35:51

Was just browsing Listener.java and found

int lag = lagMillisMax + (int)(Math.random() * (lagMillisMax - lagMillisMin));

I would assume this was supposed to be

int lag = lagMillisMin + (int)(Math.random() * (lagMillisMax - lagMillisMin));

Not awfully significant of course, and I might very well be wrong, just seems more logical. :)

Original issue: http://code.google.com/p/kryonet/issues/detail?id=9

Kryonet disconnects just after connecting

From [email protected] on July 07, 2013 19:02:06

What steps will reproduce the problem?

  1. start a server
  2. start client
  3. client keep sendTCP to server
  4. server not send anything to client

    What is the expected output? What do you see instead?
    [kryonet] Connection 1 connected: /127.0.0.1
    [kryonet] Connection 1 disconnected.
    in 12 seconds


    What version of the product are you using? On what operating system?
    2.20


    Please provide any additional information below.

    Reason and how to fixed it:

    if i am keep writing lastWriteTime will bigger than the parameter "time" for method:

    com.esotericsoftware.kryonet.TcpConnection.needsKeepAlive(long time);

    so this will case "time - lastWriteTime" < 0 and of course made it < keepAliveMillis. That is why needsKeepAlive() will always return true, and client killed it by itself.

    i fixed by adding such code in the needsKeepAlive() method and isTimedOut (long time) method, you can see details in attachment.

    Hope this helpful!!

    BTW your frame is great! and simple to use!!

Attachment: compare.jpg

Original issue: http://code.google.com/p/kryonet/issues/detail?id=34

Mavenize kryonet

From [email protected] on August 22, 2013 19:13:56

What steps will reproduce the problem?

  1. Look for kryonet on maven central

    What is the expected output? What do you see instead?
    Expected to find kryonet on maven central. It's not.

    What version of the product are you using? On what operating system?


    Please provide any additional information below.
    See this link for a mavenization of kryonet that works in my local environment.
    esialb/kryonet-mavenized@7cf2152

Original issue: http://code.google.com/p/kryonet/issues/detail?id=37

kryonet protocol

Hi,

As I dig deeper into the kryonet/kryo libraries, I appreciate the power and simplicity of the framework. Amazing work folks.

I'm trying to serialize cocoa-objects over a socket connection to kryonet server. The server is correctly matching the source class to registered class and completing the serialization at the server end.

I'm almost there, but for the following issues -

  1. The first field in the source is getting serialized to second, the second(source) to third (destination) and so-on.
  2. Strings are not getting serialized correctly because I'm not specifying the format (ascii/utf8) in the buffer. How is this done?

Will appreciate if you can point to the protocol elements to be inserted in the buffer.

Regards
Sanjeev

Reconnect handling

From [email protected] on July 29, 2010 13:59:12

A disconnect from the server is easily recognizable through Listener / disconnected. Yet there is no easy way to reconnect, which brings me to the following problems:

  1. It's not possible to get the current parameters client.getRemoteAddressTCP() respective client.getRemoteAddressTCP() - both return null when the connection is dropped
  2. There is no client.getTimeout() method, although the parameter is required for connect()
  3. A client.reconnect() would be really great

I'm using the latest 1.01 version from SVN.

Original issue: http://code.google.com/p/kryonet/issues/detail?id=4

Incorrect number of bytes in Serialization

From [email protected] on July 16, 2011 00:08:40

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?
com.esotericsoftware.kryo.SerializationException: Incorrect number of bytes (15 remaining) used to deserialize object: shared.components.SharedComponent@1508f31
at com.esotericsoftware.kryonet.TcpConnection.readObject(TcpConnection.java:148)
at com.esotericsoftware.kryonet.Server.update(Server.java:186)
at com.esotericsoftware.kryonet.Server.run(Server.java:336)
at server.network.GameServer.run(GameServer.java:263)
at java.lang.Thread.run(Thread.java:662)

What version of the product are you using? On what operating system?
Newest

Please provide any additional information below.
Using Kryo without KryoNet works without any problems.

Original issue: http://code.google.com/p/kryonet/issues/detail?id=11

server select : 100&#37; cpu (round 3)

From [email protected] on June 01, 2012 18:03:26

Problem similar to issue#19

The select still returns something !=0 when there is no network activity
The exception line 320 is thrown :

https://code.google.com/p/kryonet/source/browse/trunk/kryonet/src/com/esotericsoftware/kryonet/Server.java?spec=svn111&amp;r=111#320

The sleep is not reached because select!=0 and the connection is not closed because of the exception thrown.
maybe the connection needs to be closed there ?

I don't know if i can easily reproduce the problem

Original issue: http://code.google.com/p/kryonet/issues/detail?id=20

Problem on certain routers with the IPTOS_LOWDELAY option

From [email protected] on June 03, 2012 02:27:18

With an android Device and a router which doesn't work with IPTOS_LOWDELAY option.

The traffic is blocked when this option is enabled:
https://code.google.com/p/kryonet/source/browse/trunk/kryonet/src/com/esotericsoftware/kryonet/TcpConnection.java#76

Could you add a function to disable this option by default?
Or maybe disable this option by default.

Thx

Original issue: http://code.google.com/p/kryonet/issues/detail?id=21

Multithreaded flooding reliably broken with 2.20

From [email protected] on January 21, 2013 01:14:47

What steps will reproduce the problem?

  1. Clone https://github.com/pcarrier/kryoflood
  2. Run mvn package
  3. Observe that everything runs fine with:
    java -cp lib/kryonet-2.18-all.jar:target/kryoflood-1.0-SNAPSHOT.jar com.github.pcarrier.kryoflood.Main cs 1
  4. Observe that everything breaks with:
    java -cp lib/kryonet-2.18-all.jar:target/kryoflood-1.0-SNAPSHOT.jar com.github.pcarrier.kryoflood.Main cs 2
  5. When digging, please be patient with my benchmark coding style :)

    What is the expected output? What do you see instead?


    The server goes BufferOverflowException as soon as there are more than one client.

    What version of the product are you using? On what operating system?


    I am using kryonet-2.18-all.jar from kryonet-2.20.zip. Not sure which version that is.

    Please provide any additional information below.


    Usage:
    "cs" to run a client and a server that floods it with UDP messages
    "csu 20" to run 20 clients and a server that floods them with TCP messages
    (c for client(s), s for server, u for UDP, followed by a number to have multiple clients)

    This is the output with 2 clients:
    --- 8< ---
    % java -cp lib/kryonet-2.18-all.jar:target/kryoflood-1.0-SNAPSHOT.jar com.github.pcarrier.kryoflood.Main cs 2
    0: Infinity msg/s
    1: Infinity msg/s
    0 connected!
    1 connected!
    Exception in thread "Server@1" java.nio.BufferOverflowException
    at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:183)
    at com.esotericsoftware.kryo.io.ByteBufferOutputStream.write(ByteBufferOutputStream.java:42)
    at com.esotericsoftware.kryo.io.Output.flush(Output.java:154)
    at com.esotericsoftware.kryonet.KryoSerialization.write(KryoSerialization.java:51)
    at com.esotericsoftware.kryonet.TcpConnection.send(TcpConnection.java:192)
    at com.esotericsoftware.kryonet.Connection.sendTCP(Connection.java:59)
    at com.github.pcarrier.kryoflood.Main$1$1.run(Main.java:43)
    Exception in thread "Client" com.esotericsoftware.kryonet.KryoNetException: Incorrect number of bytes (12 remaining) used to deserialize object: SimpleTest(id=456673020, message=Hello!)
    at com.esotericsoftware.kryonet.TcpConnection.readObject(TcpConnection.java:146)
    at com.esotericsoftware.kryonet.Client.update(Client.java:239)
    at com.esotericsoftware.kryonet.Client.run(Client.java:317)
    at java.lang.Thread.run(Thread.java:722)
    Exception in thread "Client" com.esotericsoftware.kryonet.KryoNetException: Invalid object length: 0
    at com.esotericsoftware.kryonet.TcpConnection.readObject(TcpConnection.java:116)
    at com.esotericsoftware.kryonet.Client.update(Client.java:239)
    at com.esotericsoftware.kryonet.Client.run(Client.java:317)
    at java.lang.Thread.run(Thread.java:722)
    --- >8 ---

    Whereas with one client, everything runs fine:
    --- 8< ---
    % java -cp lib/kryonet-2.18-all.jar:target/kryoflood-1.0-SNAPSHOT.jar com.github.pcarrier.kryoflood.Main cs 1
    0: Infinity msg/s
    0 connected!
    0: 107526.88 msg/s
    0: 172117.05 msg/s
    0: 157480.31 msg/s
    0: 153374.23 msg/s
    0: 149700.6 msg/s
    0: 154320.98 msg/s
    0: 167224.08 msg/s
    0: 186219.73 msg/s
    0: 168918.92 msg/s
    0: 169204.73 msg/s
    --- >8 ---

Original issue: http://code.google.com/p/kryonet/issues/detail?id=30

After sending TCP data to server client disconnects

After creating a server and connecting a client things work fine. If I set client.setKeepAliveTCP(100); I can see from the server that these messsages are repeatidly being recieved by the server. But as soon as I use sendTCP(object) the client disconects

IOS connection disconnects immediately

I'm connecting to my kryonet server, from IOS using a simple socket connection API.

It disconnects as the code cannot find udpRemoteAddres

What is udpRemoteAddress, and how can I pass it from the client. From a java client, I can pass the udp port as a second param, but from IOS I see the API allows only one socket address to be passed.

Please help in understanding if I can connect to kryonet using normal socket API's or will I need a kryonet client.

Client - Register listener before connecting to srever

From [email protected] on October 12, 2013 22:19:49

This might be obvious to many people, but when i set the client up for the first time with my own listener, it didn't occur to me that the registering of the listener, had to be before the connection to the server. And i don't see any mentioning of it.

It will still work if the connection to the server is slower than what it takes to add the listener. So it's a problem where sometimes it works perfectly, and sometimes it doesn't work at all.

Maybe tell people with some bold text, that the registering the listener has to be before client.connect() so nobody will run into the same problem again?

Original issue: http://code.google.com/p/kryonet/issues/detail?id=43

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.