Search Unity

Resolved Unity Transport - CompleteSend failed with the following error code: -5

Discussion in 'NetCode for ECS' started by DDKH, Feb 17, 2021.

  1. DDKH

    DDKH

    Joined:
    Jun 13, 2013
    Posts:
    25
    Hi!

    I'm getting this error when calling EndSend():

    CompleteSend failed with the following error code: -5

    What does this error means or where i can find any info about this error code?

    Unity Transport 0.6.0-preview.7
    Unity 2020.2.4

    @timjohansson
     
    Last edited: Feb 17, 2021
    Lukas_Kastern likes this.
  2. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    -5 is not an error code I've seen before - the error codes should have more numbers in them. Which NetworkInterface are you using, the default one?
     
  3. DDKH

    DDKH

    Joined:
    Jun 13, 2013
    Posts:
    25
    Thanks for your reply!

    Yes, i create the driver by calling
    networkDriver = NetworkDriver.Create();
    which uses BaselibNetworkInterface internally.

    Pipelines (the same order):

    1. ReliableSequencedPipelineStage
    2. UnreliableSequencedPipelineStage
    3. NullPipelineStage

    This happens when trying to send 128000 bytes of data, by dividing it to small 500-byte pieces (so each piece is sending by BeginSend / EndSend)
     
  4. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    I looked in the wrong place and forgot about the new error codes in 0.6, -5 is NetworkSendQueueFull. The list of errors (without the interface specific ones) is at https://docs.unity3d.com/Packages/c...ty.Networking.Transport.Error.StatusCode.html - but for some reason it looks like it does not include the values assosiated with the codes.

    The default backend has a limited number of pending sends, you need to call NetworkDriver.ScheduleFlushSend to process them and get buffers back. You can change the queue size by setting BaselibNetworkParameter.sendQueueCapacity when creating the driver, the default size is 64.

    The reliable pipeline has another limited send window which you can control with ReliableUtility.Parameters.WindowSize, default value of 32. When you have more pending messages than can fit in the buffer send will fail and it is up to you to wait and try sending again later.
     
    BobFlame likes this.
  5. DDKH

    DDKH

    Joined:
    Jun 13, 2013
    Posts:
    25
    ok, it's clear now, thank you!
     
  6. BobFlame

    BobFlame

    Joined:
    Nov 12, 2018
    Posts:
    95
    Hi, Im using only fragmentation stage in pipeline, and I setup network driver like this:
    Code (CSharp):
    1.  
    2.             driver = NetworkDriver.Create(
    3.                 new BaselibNetworkParameter { sendQueueCapacity = 1024, receiveQueueCapacity = 1024, maximumPayloadSize = (uint)(32 * 1370) },
    4.                 new FragmentationUtility.Parameters { PayloadCapacity = 32 * 1370}
    5.                 );
    6.             pipeline = driver.CreatePipeline(typeof(FragmentationPipelineStage));
    When I use beginSend to 32 times, it return error code -5. what's problem of my code?
     
  7. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    894
    mmm I see.
    You are configuring the PayloadCapacity for the fragmentation pipeline to 32*1370 (So roughly 32 MTU). If you send that packet size, internally the fragmentation pipeline will split it more or less in 32 chunks, each less than a MTU (not the maximumPayloadSize);
    If you call BeginSend 32 times without calling EndSend and you are sending the full packet size (32*1370), you are requesting probably more than 1024 packet to be sent.

    Setting the the maximumPayloadSize to 32 * 1370 does not affect the FragmentationPipeline that it is still splitting based on the constant MTU (and that it can be source of confusion)
     
  8. BobFlame

    BobFlame

    Joined:
    Nov 12, 2018
    Posts:
    95
    I of course use beginsend with endsend accordingly. I kind of figure out fragmentation pipeline's mechanism, and I will say it a bug. because it is wasting memory buffer allocated by INetworkInterface.
    https://forum.unity.com/threads/transport-pipeline-is-wasting-sending-queue.1081271/