Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [Kryonet] - large traffic causes client disconnect  (Read 1972 times)
0 Members and 1 Guest are viewing this topic.
Offline Unimatrix325

Junior Newbie





« Posted 2012-01-23 15:09:21 »

Hi,
I have a question to kyonet lib. It seems to have problems with handling both large and numerous messages. When I send to many messages per second (hundreds) or some messages with a lot of data, the client just disconnects from the server. There is neither an exception nor an error message.
How am I supposed to prevent or handle this ?
Offline theagentd
« Reply #1 - Posted 2012-01-23 15:55:40 »

Quote
Everytime I kick someone in the balls he stops talking to me. What can I do to prevent this?
Don't kick him in the balls. xD

If he's on wireless there's a big chance the router just can't keep up. Could that be the problem?

Myomyomyo.
Offline Unimatrix325

Junior Newbie





« Reply #2 - Posted 2012-01-23 16:13:18 »

Well of course that could be the problem, but that does not answer my question. I can't just arbitrary cut down the traffic to some magic number and then expect this problem won't occur again. I would expect that if the network can't keep up, that it will try to do it's best. Of course the messages will start having delay end eventually I may get some timeout or buffer overflow or whatever. On the other hand it may be a peak traffic which will calm down in few seconds and then it should catch up.
But I need some information, that the network is not able to handle the traffic. Not just plain "client disconnects".

In another words - it seems logical to expect from a network layer/library to deliver all the data I provide. I can understand that when I give 200kB of data on a 50kB connection it will take at least 4 seconds to send it. But I don't expect the answer "nope, I can't send 200kB" :-)
Games published by our own members! Check 'em out!
Play the free demo of Revenge of the Titans!
Offline Nate

JGO Wizard


Medals: 81
Projects: 3


Esoteric Software


« Reply #3 - Posted 2012-01-23 16:30:21 »

There should be a message logged. Try setting the logging level lower, Log.DEBUG() or Log.TRACE(). If you send enough data fast enough, you can fill the buffer in your networking hardware and KryoNet will start to fill the "write buffer". When this is full, Connection#sendTCP logs a message at WARN or ERROR. See the writeBufferSize parameter on the Client and Server constructors. This should be set higher if you expect occasional peak bursts of traffic size or frequency.

Offline Unimatrix325

Junior Newbie





« Reply #4 - Posted 2012-01-23 17:48:29 »

Ah, that sounds helpful.
I set the logging levels to trace, and yes. I can see "com.esotericsoftware.kryo.SerializationException: Buffer limit exceeded writing object of type..." at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:483) now.
I tried to set larger bufferSizes for server and client (32768, 16384). It helped, but it also increased the latency terribly. Or maybe not the latency because the whole game is getting frozen every second or two.
EDIT : ah, nevermind, that was caused by large amount of logging output. So it seems to be working.
Are there some recommanded values ? Or is there some approach I can take to this ? I can set the values higher, but still, it may happen, that they will overflow. Is there some solution to this situation ?
Offline Nate

JGO Wizard


Medals: 81
Projects: 3


Esoteric Software


« Reply #5 - Posted 2012-01-23 18:53:20 »

Javadocs:

http://kryonet.googlecode.com/svn/api/com/esotericsoftware/kryonet/Client.html#Client%28int,%20int%29

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
/** @param writeBufferSize One buffer of this size is allocated. Objects are serialized to the write buffer where the bytes are
 * queued until they can be written to the socket.
 * <p>
 * Normally the socket is writable and the bytes are written immediately. If the socket cannot be written to and
 * enough serialized objects are queued to overflow the buffer, then the connection will be closed.
 * <p>
 * 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 in case the buffer is temporarily not writable. The amount of head
 * room needed is dependent upon the size of objects being sent and how often they are sent.
 * @param objectBufferSize Two (using only TCP) or four (using both TCP and UDP) buffers of this size are allocated. These
 * buffers are used to hold the bytes for a single object graph until it can be sent over the network or
 * deserialized.
 * <p>
 * The object buffers should be sized at least as large as the largest object that will be sent or received. */


Other than that, not much you can do. You probably don't want your buffers growing unbounded. Kryo doesn't properly support streaming or auto growing the buffers. The next version will, whenever I get a bunch of free time.

Offline Unimatrix325

Junior Newbie





« Reply #6 - Posted 2012-01-23 19:01:38 »

Oh, silly me. I should have read the javadoc of course. Ok that is useful info, thanks.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Try the Free Demo of Revenge of the Titans

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (84 views)
2013-05-17 22:29:12

alaslipknot (92 views)
2013-05-16 22:24:48

gouessej (124 views)
2013-05-16 01:53:38

gouessej (117 views)
2013-05-16 01:17:58

theagentd (127 views)
2013-05-15 16:01:13

theagentd (114 views)
2013-05-15 16:00:54

StreetDoggy (158 views)
2013-05-14 16:56:26

kutucuk (180 views)
2013-05-12 18:10:36

kutucuk (180 views)
2013-05-12 16:36:09

UnluckyDevil (187 views)
2013-05-12 06:09:57
Complex number cookbook
by Roquen
2013-04-24 13:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 17:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 17:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 17:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 18:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 17:17:38

Java Data structures
by Roquen
2013-03-29 14:21:12

Topic Request
by kutucuk
2013-03-22 22:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.122 seconds with 21 queries.