EsotericSoftware / kryonet

TCP/UDP client/server library for Java, based on Kryo
BSD 3-Clause "New" or "Revised" License
1.82k stars 419 forks source link

Server disconnecting when sending a lot of data in small chunks #36

Open ghost opened 10 years ago

ghost commented 10 years ago

From rj.dre...@gmail.com 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:

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

ghost commented 10 years ago

From rj.dre...@gmail.com on July 20, 2013 06:45:42

P.S. error.txt shows the Broken pipe error, error2.txt the closed connection error, which actually seems to get caused by Kryonet being unable to update the connection (of which I have no clue what that means, other than something to keep it alive perhaps?).

Thanks in advance for any insights.