Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Resolved Send fragmented pipeline erorr

Discussion in 'Unity Transport' started by Farshadfarzan368, Jun 8, 2023.

  1. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    Hello, I am trying to send a text of approximately 15 KB in fragmented pipeline, but it is not sent. It works in local mode and offline, but when I take it to the vps server, it is not sent.
    But a small amount is sent
    Do I need to make special settings in the vps server?
     
    Last edited: Jun 8, 2023
  2. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    My vps properties
    Window 10
    Cpu 4
    Ram 4
     
  3. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    Worked an send 15 kb string in local mode
    Ip 127.0.0.1

    But not work and not send in vps
    But a small amount is sent
     
  4. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    My settings
     

    Attached Files:

  5. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    Must be sent reliably
     
  6. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    By default the fragmentation pipeline is limited to 4KB payloads. See this part of the documentation for an example of how to change this value. Note that you need to configure the new value on both the server and the client.
     
  7. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    Why does it only send the first chunk? If I send a 15KB message, it should be split into four smaller chunks and then sent, but it only sends the first chunk.
     
  8. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    Why does it work locally but not in the vps?
     
  9. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    hi The problem is how to solve it



    ArgumentException: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/Kl7EgE/CMi/b/LYx8azlXZP/mbPP4/xJ4IhbKLZWF4iAIIJg7DcxT7KWirUfIOgZfGuiHuNBvDChj83l+qx8+4z//I6C1eRINJtnCD/G5UkmNwpW0LoudqLAXStOJw8pQgJq8ceHrhscgdLNCYj7+CYGuUlGBGPE/z844atcQJiEMCYMBSShxw53OTPDUMXivFJj6igjW5gdNql5RJkQITMbrfLCZyOZSKQpFzigPoFyNz43o1sDsPeAuTEMUcpR44UOLsbaFfE3kG8Jw96uix8aoWfQdr1OpK3dS2mNGd2P0z/FiSjWViHmwGyupUYBAKyqwIoRrNOj9t93CF/LmGWz3MdOcYUkZs27Jahv+PMCDKMcc49mvRGSoiXf7lsQfxh3y4hSrJo3NXuFVHwIJR0RKUgI09rj+nk8vnLIMioZCSiishOlH4ru7uagM+972H7dOydD6EhqA7MDjJe5+xydMape+O1ytYTHn5DIwEscQnUVW/LrVhUS5CS4iGpX1tttMhtgMPsqIo0ZEUGp9/Sm5IDT4jv4ZwDwOBeDmqUiOKjJ1euJsJ+epaU/uuBX5gHTdP4AczV49hOUGklTK4SN/WHXW52jxEIE77i/dVV3cnckFaOhEPKUHfdjAOFoHzaLJCfGY5v3aHpl0BlmsCbz7QkTpwfBIi4RO1vp34HcWUGUn8VuV/4E7sAjZsW1YkFsnmvavBXTru1UHtWUsfPfX+5rzNZ7msYPzA0ibKYoUj/m2OD67mH+l1odDFhUaE7BjlR8ApClRzWlR7PJnM4Xxel0I+r09akKn9hpvIfHfP/VKv58ezUvfjE9ll+mdQRlmqcb8DVlMqX0FZUZtW+CPSK0XGQScSUZK7vWNGKmnNYlfgO1pnkro/j/xMvi86SfgNF//gc="
    Unity.Collections.FixedString4096Bytes.CheckCopyError (Unity.Collections.CopyError error, System.String source) (at Library/PackageCache/com.unity.collections@1.2.4/Unity.Collections/FixedString.gen.cs:6881)
    Unity.Collections.FixedString4096Bytes..ctor (System.String source) (at Library/PackageCache/com.unity.collections@1.2.4/Unity.Collections/FixedString.gen.cs:6291)
    Unity.Collections.FixedString4096Bytes.op_Implicit (System.String b) (at Library/PackageCache/com.unity.collections@1.2.4/Unity.Collections/FixedString.gen.cs:6807)
    ServerCode.SendFragmentedDatatoClient (Netmsg_Min msg, Unity.Networking.Transport.NetworkConnection nc) (at Assets/Scripts/ServerCode.cs:2581)
    Mongo.SendProfileComplate (System.String userID, Unity.Networking.Transport.NetworkConnection nc) (at Assets/Scripts/Mongo.cs:872)
    ServerCode.userManager (Net_userinformation msg7, Unity.Networking.Transport.NetworkConnection nc) (at Assets/Scripts/ServerCode.cs:1808)
    ServerCode.OnDataClient (System.String datastring, Unity.Networking.Transport.NetworkConnection nc) (at Assets/Scripts/ServerCode.cs:900)
    ServerCode.Update () (at Assets/Scripts/ServerCode.cs:866)
     

    Attached Files:

  10. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    As the name of the type indicates,
    FixedString4096Bytes
    can only hold 4096 bytes of data. It appears that you're trying to copy a string longer than that in there. And keep in mind that those 4096 bytes also include things like the length and a null terminator for the string, so it's actually slightly less than 4096 ASCII characters that can fit in the type.
     
  11. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    Please help me to solve it in another way. I can't add blank character. The game is published and I don't have access to the client.
     
  12. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    You could try creating a
    NativeArray<byte>
    of the length of your string, copying the string into that native array, and then writing the array to the data stream writer with
    WriteBytes
    . Or more direct but less efficient, you could write the string to the data stream writer one character at a time with
    WriteByte
    . Assuming you've configured the fragmentation pipeline to allow a payload of that size, that should work.
     
  13. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    Thank you very much, it is solved. But one question, how do you know if the received data is a string or a byte array? new client send byte array old client send string
     
  14. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    I made a mistake, it's not solved, when the size should be higher than 4096, it won't be sent, even when I converted it to bytes.
     
  15. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    What is payload capacity, is it the capacity of each part or the total capacity of Array?
     
  16. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    client

    void Start()
    {
    InitializeClient();
    }


    void InitializeClient()
    {
    m_clientDrive = NetworkDriver.Create();
    _fragmentedPipeline = m_clientDrive.CreatePipeline(typeof(FragmentationPipelineStage), typeof(ReliableSequencedPipelineStage));
    m_Connection = default(NetworkConnection);

    if (serverData.ConnectToVps)
    {
    serverEndPoint = NetworkEndPoint.Parse(serverData.server_VPS_IP, serverData.ServerPort);
    }
    else if (!serverData.ConnectToVps)
    {
    serverEndPoint = NetworkEndPoint.Parse(serverData.server_Local_IP, serverData.ServerPort);
    }

    m_clientToServerConnection = m_clientDrive.Connect(serverEndPoint);

    }

    void Update()
    {


    ////////// menu manager

    if (serverEndPoint.IsValid && m_clientToServerConnection.IsCreated == false)
    {
    m_clientToServerConnection = m_clientDrive.Connect(serverEndPoint);
    }


    DataStreamReader strm; // zarf nagah darande data karbar
    NetworkEvent.Type cmd; // diss ,conect ,model conecting


    while ((cmd = m_clientToServerConnection.PopEvent(m_clientDrive, out strm)) != NetworkEvent.Type.Empty)
    {

    if (cmd == NetworkEvent.Type.Connect)
    {
    print("connnect");
    connectedtoserver = true;
    setuserinformation();
    }
    else if (cmd == NetworkEvent.Type.Disconnect)
    {

    print("clientdisconect");
    connectiontype = "reconect";
    connectedtoserver = false;
    ConecctetComplet = false;
    DissconnectFromServer();
    m_Connection = default(NetworkConnection);

    return;
    }

    else if (cmd == NetworkEvent.Type.Data)
    {
    NativeArray<byte> nab = new NativeArray<byte>(strm.ReadInt(), Allocator.Temp);
    strm.ReadBytes(nab);
    byte[] ba = new byte[0];
    ba = nab.ToArray();
    OnDataServer(ba);
    }
    }
    }
    /////////// server



    void Start()
    {
    InitializeServer();
    }

    void InitializeServer()
    {
    m_serverDrive = NetworkDriver.Create();
    _unreliblePipeline = m_serverDrive.CreatePipeline(typeof(ReliableSequencedPipelineStage));
    _fragmentedPipeline = m_serverDrive.CreatePipeline(typeof(FragmentationPipelineStage), typeof(ReliableSequencedPipelineStage));

    var addr = NetworkEndPoint.AnyIpv4;
    addr.Port = serverData.ServerPort;
    if (m_serverDrive.Bind(addr) != 0)
    {
    //////print("filue bind");
    }
    else
    {
    //////print("server start");
    m_serverDrive.Listen();
    }
    m_connecsions = new NativeList<NetworkConnection>(serverData.ccu, Allocator.Persistent);
    }


    void Update()
    {


    m_serverDrive.ScheduleUpdate().Complete();



    while (true)
    {
    NetworkConnection com = m_serverDrive.Accept();


    if (!com.IsCreated)
    break;
    m_connecsions.Add(com);
    connecsionscID.Add(com);

    }


    for (int i = 0; i < m_connecsions.Length; i++)
    {

    DataStreamReader strm; // zarf nagah darande data karbar
    NetworkEvent.Type cmd; // diss ,conect ,model conecting

    while ((cmd = m_serverDrive.PopEventForConnection(m_connecsions, out strm)) != NetworkEvent.Type.Empty)
    {

    if (cmd == NetworkEvent.Type.Connect)
    {
    StartCoroutine(AiRoom());
    }

    else if (cmd == NetworkEvent.Type.Disconnect)
    {
    print("diiiiiiiiiiisc");
    AfterDisConnection(connecsionscID, 0);
    m_connecsions.RemoveAtSwapBack(i);
    connecsionscID.RemoveAtSwapBack(i);
    }

    else if (cmd == NetworkEvent.Type.Data)
    {
    NativeArray<byte> nab = new NativeArray<byte>(strm.ReadInt(), Allocator.Temp);
    strm.ReadBytes(nab);
    byte[] ba = new byte[0];
    ba = nab.ToArray();
    OnDataClient(ba);
    }

    }

    }







    }
     
  17. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    public void SendFragmentedDatatoClientList(byte[] bn, List<string> UserList)
    {

    NativeArray<byte> nb = new NativeArray<byte>(bn, Allocator.Temp);


    foreach (var item in UserList)
    {
    if (m_serverDrive.BeginSend(_fragmentedPipeline, ncShoter(item), out var senddata) == 0)
    {
    senddata.WriteInt(bn.Length);
    senddata.WriteBytes(nb);
    print("befor send " + bn.Length);
    m_serverDrive.EndSend(senddata);
    }
    }


    }
     
  18. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    Where is the problem, why does it not send if the array size exceeds 4096?
     
  19. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    I'm pretty sure I already answered this question before in one of your other threads. If you need to send more than 4096 bytes on a fragmented pipeline, you need to configure its maximum payload size accordingly. This is documented here.