Skip to content

Out of bounds exception #8

Open

Description

@genaray

Was already posted on the discord... theres a weird exception going on when using the relay... It happens completly randomly but is game breaking.
https://media.discordapp.net/attachments/563033158480691211/803724646826377226/unknown.png?width=1440&height=178

Activity

  1. timmeh4242 commented on Apr 22, 2021

    @timmeh4242

    We're seeing this as well, and also inconsistently.

  2. ajaybirla commented on Apr 30, 2021

    @ajaybirla

    Hi All,

    I'm not getting this issue any more after doing the below changes in the Send function.

    Note: I'm not sure if this is the correct way to fix this issue but it worked for me.

    public bool Send (int hostId, int connectionId, int channelId, byte [] buffer, int size, out byte error)
    {
        if (!Enabled) return NetworkTransport.Send (hostId, connectionId, channelId, buffer, size, out error);
    
        ++size;
    
        if (!isClient)
        {
            size += 8;
    
            // ********************************************************
            // Birla: Resizing 'buffer' array as 'buffer.Length < size'
            // ********************************************************
            if (buffer.Length < size)
            {
                Debug.LogErrorFormat ("<color=cyan>Resizing 'buffer' array as buffer.Length ({0}) < size ({1})</color>", buffer.Length, size);
    
                byte [] tempBuffer = new byte [size];
    
                Buffer.BlockCopy (buffer, 0, tempBuffer, 0, buffer.Length);
    
                buffer = tempBuffer;
            }
            // ********************************************************
    
            int connectionIdOffset = size - 9;
    
            for (byte i = 0; i < sizeof (ulong); i++) buffer [connectionIdOffset + i] = ((byte) ((ulong) connectionId >> (i * 8)));
        }
    
        buffer [size - 1] = (byte) MessageType.Data;
    
        return NetworkTransport.Send (hostId, relayConnectionId, channelId, buffer, size, out error);
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions