Skip to content

Client gets NullReferenceException when host shuts down. #1391

@ImDanTheDev

Description

@ImDanTheDev

Describe the bug
With one or more clients connected to a host, all remote clients throw a NullReferenceException when the host calls Shutdown().

To Reproduce

  1. Start a host.
  2. Wait for the host's server to start.
  3. Connect a client to the host.
  4. Wait for the client to connect.
  5. Run NetworkManager.Singleton.Shutdown() on the host.
  6. In the client's console output, notice a NullReferenceException entry.

Actual outcome
After the host is shutdown, connected clients are disconnected, and an error is logged in each client's console. The host does successfully shutdown. The client does successfully disconnect from the server.

Expected outcome
The client should cleanly disconnect from the server without an error message.

Screenshots
https://user-images.githubusercontent.com/2303421/140042480-001892be-6e73-4a59-9739-cd91d1be1254.mp4
Unity_cFnySnehQO

Environment (please complete the following information):

  • OS: Windows 11
  • Unity Version: 2021.2.0f1
  • Netcode Version: 1.0.0-pre.3
  • Netcode Commit: 3e4df72

Additional context
I experience the issue while using UNetTransport and default inspector settings for both the NetworkManager and UNetTransport.

Attached is a project to reproduce the issue(NullRefReprod.zip). Make two copies of the project. Open ReprodScene and click Play in both copies. In the first project, click button "1. Start Host." In the second project, click button "2. Join Host @ 127.0.0.1:7777." Once the client has joined the host, click button "3. Shutdown" in the host project. Now the client will disconnect and log a NullReferenceException.

Metadata

Metadata

Assignees

Labels

priority:lowThis issue has low priority and will take some time to be resolvedtype:bugBug Report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions