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

Occasional error on disconnect (websockets) #201

Open
DevDavey opened this issue Jan 23, 2023 · 4 comments
Open

Occasional error on disconnect (websockets) #201

DevDavey opened this issue Jan 23, 2023 · 4 comments

Comments

@DevDavey
Copy link

DevDavey commented Jan 23, 2023

Sometimes when the browser tab is closed a few error messages will be thrown on the server and then a repeating error message which hangs the server completely. Generally clients can disconnect perfectly fine but ~1/20 times this happens.

image

InvalidOperationException: The current state of the connection is not Open.
WebSocketSharp.WebSocket.Send (System.Byte[] data) (at Library/PackageCache/com.community.netcode.transport.websocket@858f6df327/Runtime/Libraries/websocket-sharp/websocket-sharp/WebSocket.cs:3370)
Netcode.Transports.WebSocket.WebSocketPeer.Send (System.Byte[] data) (at Library/PackageCache/com.community.netcode.transport.websocket@858f6df327/Runtime/WebSocketPeer.cs:25)
Netcode.Transports.WebSocket.WebSocketServerConnectionBehavior.Send (System.UInt64 clientId, System.ArraySegment`1[T] data) (at Library/PackageCache/com.community.netcode.transport.websocket@858f6df327/Runtime/WebSocketServerConnectionBehavior.cs:75)
Netcode.Transports.WebSocket.WebSocketTransport.Send (System.UInt64 clientId, System.ArraySegment`1[T] data, Unity.Netcode.NetworkDelivery delivery) (at Library/PackageCache/com.community.netcode.transport.websocket@858f6df327/Runtime/WebSocketTransport.cs:91)
Unity.Netcode.NetworkManager+NetworkManagerMessageSender.Send (System.UInt64 clientId, Unity.Netcode.NetworkDelivery delivery, Unity.Netcode.FastBufferWriter batchData) (at Library/PackageCache/[email protected]/Runtime/Core/NetworkManager.cs:179)
Unity.Netcode.MessagingSystem.ProcessSendQueues () (at Library/PackageCache/[email protected]/Runtime/Messaging/MessagingSystem.cs:768)
Unity.Netcode.NetworkManager.OnNetworkPostLateUpdate () (at Library/PackageCache/[email protected]/Runtime/Core/NetworkManager.cs:1641)
Unity.Netcode.NetworkManager.NetworkUpdate (Unity.Netcode.NetworkUpdateStage updateStage) (at Library/PackageCache/[email protected]/Runtime/Core/NetworkManager.cs:1538)
Unity.Netcode.NetworkUpdateLoop.RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage updateStage) (at Library/PackageCache/[email protected]/Runtime/Core/NetworkUpdateLoop.cs:185)
Unity.Netcode.NetworkUpdateLoop+NetworkPostLateUpdate+<>c.<CreateLoopSystem>b__0_0 () (at Library/PackageCache/[email protected]/Runtime/Core/NetworkUpdateLoop.cs:268)
NullReferenceException: Object reference not set to an instance of an object
Unity.Netcode.FastBufferWriter.Dispose () (at Library/PackageCache/[email protected]/Runtime/Serialization/FastBufferWriter.cs:121)
Unity.Netcode.MessagingSystem.CleanupDisconnectedClient (System.UInt64 clientId) (at Library/PackageCache/[email protected]/Runtime/Messaging/MessagingSystem.cs:438)
Unity.Netcode.MessagingSystem.ClientDisconnected (System.UInt64 clientId) (at Library/PackageCache/[email protected]/Runtime/Messaging/MessagingSystem.cs:429)
Unity.Netcode.NetworkManager.OnClientDisconnectFromServer (System.UInt64 clientId) (at Library/PackageCache/[email protected]/Runtime/Core/NetworkManager.cs:2159)
Unity.Netcode.NetworkManager.HandleRawTransportPoll (Unity.Netcode.NetworkEvent networkEvent, System.UInt64 clientId, System.ArraySegment`1[T] payload, System.Single receiveTime) (at Library/PackageCache/[email protected]/Runtime/Core/NetworkManager.cs:1875)
Unity.Netcode.NetworkManager.OnNetworkEarlyUpdate () (at Library/PackageCache/[email protected]/Runtime/Core/NetworkManager.cs:1596)
Unity.Netcode.NetworkManager.NetworkUpdate (Unity.Netcode.NetworkUpdateStage updateStage) (at Library/PackageCache/[email protected]/Runtime/Core/NetworkManager.cs:1532)
Unity.Netcode.NetworkUpdateLoop.RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage updateStage) (at Library/PackageCache/[email protected]/Runtime/Core/NetworkUpdateLoop.cs:185)
Unity.Netcode.NetworkUpdateLoop+NetworkEarlyUpdate+<>c.<CreateLoopSystem>b__0_0 () (at Library/PackageCache/[email protected]/Runtime/Core/NetworkUpdateLoop.cs:208)

This is the error message that loops and hangs the server:

NullReferenceException: Object reference not set to an instance of an object
Unity.Netcode.MessagingSystem.ProcessSendQueues () (at Library/PackageCache/[email protected]/Runtime/Messaging/MessagingSystem.cs:756)
Unity.Netcode.NetworkManager.OnNetworkPostLateUpdate () (at Library/PackageCache/[email protected]/Runtime/Core/NetworkManager.cs:1641)
Unity.Netcode.NetworkManager.NetworkUpdate (Unity.Netcode.NetworkUpdateStage updateStage) (at Library/PackageCache/[email protected]/Runtime/Core/NetworkManager.cs:1538)
Unity.Netcode.NetworkUpdateLoop.RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage updateStage) (at Library/PackageCache/[email protected]/Runtime/Core/NetworkUpdateLoop.cs:185)
Unity.Netcode.NetworkUpdateLoop+NetworkPostLateUpdate+<>c.<CreateLoopSystem>b__0_0 () (at Library/PackageCache/[email protected]/Runtime/Core/NetworkUpdateLoop.cs:268)

Unity 2022.2.0b16
Netcode for GameObjects 1.2.0

@Alexei-Grigarovich
Copy link

I have the same situation. Did you solve it somehow?

@DevDavey
Copy link
Author

@Alexei-Grigarovich Switched to Fish-Networking 👍

@eriksca
Copy link

eriksca commented Mar 6, 2023

disconnectIssue

Can you try adding null conditional operator o nline 26? I had a similar problem when disconnecting a client, both in editor and webgl build and that solved some issues

@Xortrox
Copy link

Xortrox commented Oct 17, 2023

It seems your suggestion got added already but this also seems missing in the DisconnectRemoveClient calls perhaps from what I saw last time

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

4 participants