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

NullReferenceException in HlapiClient:95 when client starts #50

Closed
TobiasWehrum opened this issue Aug 30, 2017 · 5 comments
Closed

NullReferenceException in HlapiClient:95 when client starts #50

TobiasWehrum opened this issue Aug 30, 2017 · 5 comments

Comments

@TobiasWehrum
Copy link

TobiasWehrum commented Aug 30, 2017

Context

A NullReferenceException gets thrown exactly once on a client when we start our app - maybe before the client is connected. It originates from HlapiClient.cs:95 because "connection" is null.

private bool Send(ArraySegment<byte> packet, byte channel)
        {
            if (_network.PreprocessPacketToServer(packet))
                return true;

            var length = _network.CopyPacketToNetworkWriter(packet, _sendWriter);

            // the next line is line 95
            if (!NetworkManager.singleton.client.connection.SendBytes(_sendWriter.AsArray(), length, channel))
            {
                return false;
            }

            return true;
        }

Expected Behavior

No exceptions or errors thrown on startup.

Actual Behavior

A NullReferenceException when the client tries to use connection before it is available (probably before it is connected?).

Your Environment

  • Dissonance version used: 3.0.0
  • Unity version: 5.6.0f3 (64 bit)
  • Editor Operating System and version: Windows 7
  • Build Settings: Tested only in Editor
@TobiasWehrum TobiasWehrum changed the title NullReferenceException NullReferenceException in HlapiClient:95 when client starts Aug 30, 2017
@martindevans
Copy link
Member

Hi Tobias,

I suspect this is a duplicate of the same fundamental issue in #48. Could you try the workaround I mention here?

@TobiasWehrum
Copy link
Author

Hi Martin, works! Will this be in the next version of Dissonance?

@martindevans
Copy link
Member

Yep, assuming Gabe doesn't have any problems with it and it passes code review it should be in the next version of Dissonance :)

@TobiasWehrum
Copy link
Author

Fingers crossed for that. Thanks!

@martindevans
Copy link
Member

Hi Tobias,

Since this is a duplicate of #48 I'll close it now. If you want to get alerts about comments in that thread click the "subscribe" button on the right of the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants