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.
  2. Dismiss Notice

Send large message using HLAPI

Discussion in 'Multiplayer' started by rishi-ranjan, Oct 18, 2015.

  1. rishi-ranjan

    rishi-ranjan

    Joined:
    Oct 7, 2015
    Posts:
    22
    Hi,
    I want to encode the PNG of one client to the server. I tried sending the encoded PNG using Command on both channel 0 and 1 but I get an error message saying these channel have MTU size of 1500 and message cannot be fragmented.

    I tried LLAPI along with HLAPI to open a separate port at LLAPI but I am getting an error saying that only one NetworkManager is allowed in the scene.

    What is the best way to send a message which is 50,000 bytes using HLAPI?

    I understand I have to add an Unreliable channel to my ConnectionConfig but I am not able to figure out how to get access to current ConnectionConfig in NetworkBehavior.
     
    Last edited: Oct 18, 2015
  2. rishi-ranjan

    rishi-ranjan

    Joined:
    Oct 7, 2015
    Posts:
    22
    I have added one extra channel in NetworkManager's advanced configuration. But this chanlle #2 is not visible in NetworkBehavior if I send a Command on Channel 2.

    I also tried changing the Channel#1 to Unreliable Fragmented but it gives an error message
    "no free events for long message".
     
    Last edited: Oct 18, 2015
  3. Noob4Sale

    Noob4Sale

    Joined:
    Mar 10, 2015
    Posts:
    11
    Since the size is large(and important) you need to use ReliableFragmented ,break the data up in smaller byte arrays and reassemble the data at the receiving end.
     
  4. rishi-ranjan

    rishi-ranjan

    Joined:
    Oct 7, 2015
    Posts:
    22
    The data is not important. I am looking for a sample to do this since I have not been able to find what does Unity APIs expect me to do do to send data on Fragmented channel.

    Also my understanding from blog is that I don't have to fragment and reassemble the message. Unity will take care of it if I use Fragmented channel.
     
    Last edited: Oct 18, 2015
  5. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    use the NetworkSettings custom attribute:

    [NetworkSettings(channel=2)]
    class ColorSync : NetworkBehaviour
     
  6. rishi-ranjan

    rishi-ranjan

    Joined:
    Oct 7, 2015
    Posts:
    22
    The script has some data which needs to go on reliable channel but data for screen capture should go on unreliable fragmented channel.

    I don't expect my data to be lost on Local wifi so I changed the script as per above suggestion to send all the data on channel 2. But even sending 2764 byte[] array, I get an error "no free events for long message"


    My understanding is that UnreliableFragmented can support MTU*32 size packets. I have read recommendations in the link but I am still not sure why 2764 bytes packets are not being sent.
     
  7. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    "no free events" means that the channel's packet queue is full, not that the MTU was exceeded. You are sending packets at a rate the the network cannot handle.
     
  8. rishi-ranjan

    rishi-ranjan

    Joined:
    Oct 7, 2015
    Posts:
    22
    Got it. We were using our own C++ plugin over raw socket to send the data captured earlier. We wanted to move to Unity networking so we don't have to maintain native code for different platform.

    For now we will keep using the native code plugin till we have better understanding of Unity networking and how we can send large data per frame.
     
  9. Scramblejams

    Scramblejams

    Joined:
    Oct 19, 2015
    Posts:
    7
    @seanr

    Could you provide an overview of best practices and what kind of performance we can expect when sending large data?