Search Unity

How should I handle "no free events for long message"?

Discussion in 'Multiplayer' started by thorbjrn, Nov 30, 2015.

  1. thorbjrn

    thorbjrn

    Joined:
    Nov 23, 2015
    Posts:
    2
    I am working on a Unity project in which I need both a video- and audio stream running.

    I am (perhaps foolishly?) using the HLAPI networking system for this, but it seems that I always fill up the outgoing queue for network messages, and I very quickly get the warning "no free events for long message" (followed by an error: "Failed to send big message"), causing a large part of following messages to not being send or received - this also often causes the client to gets disconnected.

    I have tried messing around with the ConnectionConfig when creating NetworkClients, but have not found any values that help with the problem.
    I am using both the Qos-Unreliable channel (for audio etc.) and Qos-UnreliableFragmented (for video).
    I am trying to send a video-image (~20 KB) 10-30 times a second.

    Is there anyway to empty the queue of outgoing messages?
    Is there some configuration-values that I should use to make this possible?
    Or should I use the LLAPI system (or .NET sockets maybe?) instead?
     
  2. thorbjrn

    thorbjrn

    Joined:
    Nov 23, 2015
    Posts:
    2
    Allright, I figured out how to partly solve the problem..: I needed to change the maximum packet size, which is only configurable when initializing "NetworkTransport" (LLAPI) - i.e. calling NetworkTransport.Init().
    So, before initializing any part of the network, I create a GlobalConfiguration with MaxPacketSize = 65000 and call NetworkTransport.Init() with the GlobalConfiguration as parameter.

    I still get the error if the network bandwidth is too low for the messages, however.
     
  3. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    Don't know if you're still interested in replies to this, but I came across it in google so thought I'd add some info.

    Be careful setting a max packet size beyond 1500. It's beyond MTU, which is a standard you might not want to exceed (your packets might not be processed on the internet).
    Look into connectionConfig.MaxSentMessageQueueSize instead, which will raise the limit you're hitting (how many messages can be queued for sending at a time).

    Read here for info on MTU:
    https://en.wikipedia.org/wiki/Maximum_transmission_unit
     
  4. notseanr

    notseanr

    Joined:
    Jan 15, 2016
    Posts:
    22
    20KB 30 times a second is a lot.

    A fragmented channel is still bound by the MTU of ~1400 bytes, it just fragments each larger user message into many protocols message inside the LLAPI.

    20K x 30 = 600K bytes.

    600K / 1400 = about 428 message per second.

    I don't think the LLAPI can handle that amount of throughput. I'd suggest trying to keep the throughput below 100 msgs per second.