OnSendBufferFull messages


Is this sent at all on the Unity plugin? We're having some issue with clients disconnecting when we have a lot of data (e.g. sending them the current level state) and was trying to figure out if it's a send buffer issue - however this event apparently isn't raised (it's not in the documentation as a Mono method that gets called at any rate).



  • Tobias
    This error is only used server-side. Clients do their best to send anything you want to up to the point of causing a out of memory exception.

    The best way to improve these issues is to reduce sent data. Try to organize your data into more compact messages (e.g. use byte[] instead of a hashtable with keys and byte values) or skip data entirely or send it only "on demand".

    So: What are you trying to achieve?
  • aha :)

    OK, so we're joining in mid-game, and the master is sending the current state of play (photonViewID for each creature, state data such as health, position et al.) which is quite a chunk of data.
    Also whilst Unity is loading into the level other RPCs are being raised (we're setting PhotonNetwork.isMessageQueueRunning = false before Application.LoadLevel and back to true in Awake, so it'll be queueing any RPCs being raised).

    Clients that are either on slow connections or don't load in quick enough will be disconnected before it's finished the Application.LoadLevel...
  • dreamora
    That sounds like you forgot to disable the receiving flag.
    As with Unity Networking, its recommended and basically required to disable sending and receiving while you enter loadlevel and reenable it afterwards again once the scene is ready
  • which one's the receiving flag?

    We're setting PhotonNetwork.isMessageQueueRunning to false (and back to true once loaded in), should I be setting something else?
  • dreamora
    There is also SetReceivingEnabled
    I think the examples actually contain it and show its usage.

    Question here would be more: what happens if you get stuck in loading too long so photon no longer talks to the server cause .Service was not called
  • gotcha, will take a look - I've been chopping out RPCs to see if that helps and it's still disconnecting - at exactly the point 90% into the level load where it locks up....
  • ok, tried SetReceivingEnabled(0,false) - doesn't seem to stop the serialized data, and doesn't prevent the timeout. Using LoadLevelAsync as it garbage collects the previous scene it hangs for ~10 seconds which I guess also stops the keepalive thread.

    Any way to prevent this happening?
  • dreamora
    There is also SetSendingEnabled () in case you send out serialization
  • Tobias
    If you set isMessageQueueRunning to false, the connection will be kept up in the background. As no script is updated while actually loading, you don't have to do anything else. Just make sure you re-enable the queue after loading.
    The server is sending stuff when someone joins? You usually don't have to send something extra when a player joins in PUN. Buffered events are sent by Photon (the actual server), not by any unity client.
    Or do you mean Photon?
    Not sure who is sending the bunch of data.