-
-
Notifications
You must be signed in to change notification settings - Fork 837
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Calling the StopHost method (internally StopClient) results in a NullReferenceException (NetworkServer.localConnection is null) if it is called after the StartHost has previously failed.
In other words: It is not possible to reset the mode to offline if server or client creation fails (e.g. if the socket address, protocol, network address or connection is already in use (System.Net.Sockets.SocketException).
[IMPORTANT] How can we reproduce the issue, step by step:
- Start as Host with instance A.
- Start a second Host with instance B.
- An exception (
System.Net.Sockets.SocketException, code0x80004005) will occur on instance B, which is correct. - The
NetworkManager.singleton.modeof instance B is still host. - Call
StopHoston instance B to set the mode to offline. - A
NullReferenceExceptionwill occur because theNetworkServer.localConnectionis null in theStopClientmethod that is called internally. This should be caught. - The mode on instance B remains Host instead of offline.
Expected behavior
After calling StopHost/Client, the NetworkManager.singleton.mode should be offline. Even if an exception occurs when calling.
Is there any other way to reset the mode to offline?
Desktop (please complete the following information):
- OS: Windows
- Build target: all
- Unity version: 2022.3.62f1
- Mirror branch: 96.0.1 from Unity Asset Store
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working