Skip to content

Write past end of buffer error when sending byte[] using SendNamedMessage #2363

@Robotnik08

Description

@Robotnik08

Description

This bug is about Custom Messages.
When trying to send a byte[] Using SendNamedMessage you get a "Write past end of buffer error"

Reproduce Steps

  1. Write a script that sends a simple byte[] to a client.
  2. The FastBufferArray will write perfectly fine, but The SendNamedMessage will get an "Write past end of buffer error";

Actual Outcome

SendNamedMessage with a byte[] will give an error

Expected Outcome

The written FastBufferArray will be send without issue

My code:

public void SendChunkMessage(byte[] messageContent, ulong clientID)
    {
        int writeSize = FastBufferWriter.GetWriteSize(messageContent);
        FastBufferWriter writer = new FastBufferWriter(writeSize, Allocator.Temp);
        CustomMessagingManager customMessagingManager = NetworkManager.CustomMessagingManager;
        using (writer)
        {
            writer.TryBeginWrite(writeSize);
            writer.WriteBytes(messageContent, writeSize, 0);
            Debug.Log("Written to FastBufferWriter");
            if (IsServer)
            {
                customMessagingManager.SendNamedMessage("Chunk", clientID, writer);
            }
        }
        Debug.Log("Send to client");
    }

My error:
image

Environment

  • OS: Windows 10 pro
  • Unity Version: 2022.2.0b16
  • Netcode Version: 1.1.0

Metadata

Metadata

Assignees

Labels

priority:lowThis issue has low priority and will take some time to be resolvedstat:importedStatus - Issue is tracked internally at Unitytype:bugBug Report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions