Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out of bounds exception #8

Open
genaray opened this issue Jan 26, 2021 · 2 comments
Open

Out of bounds exception #8

genaray opened this issue Jan 26, 2021 · 2 comments

Comments

@genaray
Copy link

genaray commented Jan 26, 2021

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

@timmeh4242
Copy link

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

@ajaybirla
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants