Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Resolved Max payload size in ConnectionApprovalCallback

Discussion in 'Netcode for GameObjects' started by bbangerter, Dec 8, 2022.

  1. bbangerter

    bbangerter

    Joined:
    Sep 17, 2014
    Posts:
    7
    Does anyone by chance know the max payload size of the NetworkManager.ConnectionApprovalRequest.Payload field is?

    Similar question for the Unity Gaming Service lobby.
    What is the max size of data for non-indexed and/or indexed data?
     
  2. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    435
    Hi @bbangerter , I asked this to our teams and will get back here once I have an answer from them
     
  3. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    435
    Hi @bbangerter , I've got an answer!

    This is documented if you dig into the REST API docs, but is kinda hard to find.

    Lobby Data:
    • Max Properties: 20
    • Non-indexed: 2 KB / each
    • Indexed: 128 B / each
    • Max # of Indexed Strings: 5
    • Max # of Indexed Numbers: 5
    Player Data:
    • Max Properties: 10/player
    • Max Size: 2KB
    • Not indexable
    https://services.docs.unity.com/lobby/v1#tag/Lobby/operation/updateLobby

    We're adding this to the docs so it becomes easier to find this info in the future. Thanks for asking the question!
     
  4. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    435
    "The ConnectionApprovalRequest.Payload itself has no size limit. It has been designed to use a byte[] and not care about the buffer size.
    However, the lower level messaging stack and the transport layer migh have limitations.

    ConnectionApprovalRequest.Payload comes from the ConnectionRequestMessage.ConnectionData.

    The ConnectionData is deserialized by reading:
    • one int (number of MessageVersionData)
    • that same number of MessageVersionData items
    • one ulong confighash
    • the ConnectionData itself
    So, I would expect the maximum ConnectionApprovalRequest.Payload to be whatever the MessagingSystem allows for FBR/FBW minus ten to twenty bytes.

    On the SDK side the only limit we impose is that a message can't be larger than what we can encode in a signed int, so... basically there's no practical limit at all. But there's a certain point where the transport will reject it and I think that's configurable."
     
  5. bbangerter

    bbangerter

    Joined:
    Sep 17, 2014
    Posts:
    7
    Thanks for the update. Much appreciated.
     
    RikuTheFuffs likes this.