Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice
  2. We've opened up a space to discuss, share feedback, and showcase everything related to the Unity Shader Graph! Come show us what you've made.
    Dismiss Notice

ChannelBuffer buffer limit of 16 packets reached.

Discussion in 'Connected Games' started by FStar, Nov 9, 2015.

  1. FStar

    FStar

    Joined:
    Sep 11, 2015
    Posts:
    50
    Hi,

    I'm trying to send a sequence of messages (terrain data) to a specific client using HLAPI. It works ok mostly but I get these errors:

    ChannelBuffer buffer limit of 16 packets reached.
    UnityEngine.Networking.NetworkConnection:SendByChannel(Int16, MessageBase, Int32)

    and this info row:
    no free events for message

    I'm using a ReliableSequenced channel.

    I've tried finding a setting for that channel buffer size but have found none. I've tried sending just a few messages (about 8) and then yielding to next update before sending more data. Each message sent is well below 1.4kb. but I need to send a bunch of them when a player moves into new terrain, currently maybe 30 but I'm looking to increase that number when I increase the view distance.

    Any ideas what to do? Am I using the wrong approach entirely or is there some setting that can fix this?
     
  2. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
  3. FStar

    FStar

    Joined:
    Sep 11, 2015
    Posts:
    50
    Ah, there it is, thanks!

    But, ok, seems my problem should be solved by change of my code rather than upping this limit. What would be the best way to approach this then?

    I want to send the data fast enough not to make the world load too slowly on the client but slow enough that my server can handle a fairly big amount of simultaneous players.

    There is a bigger chunk that needs to be sent after login and then smaller chunks as the player moves around in the world and explores new areas. The map is not generated from a seed, so I can't regenerate it on the client. It needs to be sent from the server.

    Should I make packet size larger to be able to send fewer packages? Or should a put in some artificial delay between SendByChannel calls? But what happens in that case when more users logs in, there is a big risk that the total send rate becomes too much at some point and the buffer runs out anyway. I'm not sure delays are good also because they are happening in a function that is called from the game loop...

    I tried yielding from my coroutine that sends after each message but that makes the sending too slow, unless I update the global send rate, but that might be bad for the overall performance?

    Or should I switch to TCP for this kind of thing?

    Any help is welcome. The documentation of the networking APIs is not very informative and it's lacking any kind of more advanced examples. I don't doubt that the API is very capable, but it's not easy to get into.
     
  4. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    These buffers are per-connection, so additional simultaneous players will not effect the send rates of each other on the server.

    You could use a "fragmented" channel to send larger packets. How much data are you talking about?
     
  5. FStar

    FStar

    Joined:
    Sep 11, 2015
    Posts:
    50
    Ok, I was hoping that it was per channel :)

    I'm using fragmented reliable currently. I don't have anything in place to check for missing chunks in the client so I need to stay with reliable for now. Order of packages does not matter.

    It's very experimental so far. Currently I'm sending about 12 - 30 packages of about 1kb each per 5 terrain squares (can be tweaked) that the player moves. How many packages needs to be sent depends on player speed and direction and of course the size of terrain tiles. I'm using small tiles now (1x1 units) but will increase them to double size later if I see performance problems.

    I have to improve this later to be able to up the view distance, buffering up larger chunks at slower rates while the player is standing still, send aggregated lower resolution tile info for tiles further away etc. But I will also need to add more data about each tile later which will in crease the data size. There will also be objects in the world that needs to be spawned. So overall network traffic will increase as the game grows.

    I've not built this kind of thing before so I'm learning as I go. Chunk loading worlds can be done in many ways I imagine. I'm not sure if it is best to send one row of tiles for each tile the player moves or to send much larger chunks of the world but more seldom.
     
  6. FStar

    FStar

    Joined:
    Sep 11, 2015
    Posts:
    50
    I found a bug in my code that made it send a lot more terrain tiles than I wanted. Now that it is fixed I do not have this problem anymore. It's now in line with what I described and uNet handles it well with default configuration.

    I still learned some important stuff from your answers seanr, thanks!
     
  7. diego-vieira

    diego-vieira

    Joined:
    Mar 27, 2015
    Posts:
    24
    @FStar hey, about what you said: "I'm not sure if it is best to send one row of tiles for each tile the player moves or to send much larger chunks of the world but more seldom.", have you discovered which one is better?
     
  8. SCalleSimumak

    SCalleSimumak

    Joined:
    Jun 26, 2018
    Posts:
    1
    Hi! Same issue! Sorry but I can't find how to increase MaxPendingBuffer. Can seanr explain it, please.

    I'm sending from client, an image as byte array, no more than 40.000bytes 5 times per seccond... at the begining, I can handel it by the server and render this image, by in a few seconds, the texture starts to render with errors and show on the console:
    ChannelBuffer buffer limit of 16 packets reached.

    Thanks.