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

Exception during websocket.SendMessage result in broken state #232

Open
Fafou opened this issue Oct 10, 2024 · 1 comment
Open

Exception during websocket.SendMessage result in broken state #232

Fafou opened this issue Oct 10, 2024 · 1 comment

Comments

@Fafou
Copy link

Fafou commented Oct 10, 2024

Hi,
First of all, I'm using colyseus 0.14.21 on android VR Headset device to create a VR game and I use the network ability of colyseus to create a viewer for spectator on windows device, so thank for this great library.

Some time sending message in a room result on exception, for exemple:

Unity   : One or more errors occurred. (The remote party closed the WebSocket connection without completing the close handshake.) 
Unity   :   at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions)
Unity   :   at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken)
Unity   :   at NativeWebSocket.WebSocket.SendMessage (System.Collections.Generic.List`1[T] queue, System.Net.WebSockets.WebSocketMessageType messageType, System.ArraySegment`1[T] buffer)

But sometime I had an other kind of exception, sorry I didn't kept a copy of the exception message, but it's something like You can not send message because socket it's in abnormal state: abort

After an exception in send message, the room stay broken, no more message will be sent.

I think this kind of exception come because of poor wifi, with "lot of" devices.

That is annoying, it's that the room didn't send message anymore.

After some debugging, I found a guilty in send message function
If exception occured, the flag isSending is never reseted, I try to move :

// Note that we've finished sending.
lock (OutgoingMessageLock)
{
    isSending = false;
}

few line upper, in the finally block, and now, when exception occure, I get this exception 5 or 6 time because I try to send message on each frame, but after 100ms the socket is detected as broken and a reconnect occure. So, I my viewer I can have a freeze during less than 1 second but after the reconnection all object start moving.

I will try to make a Pull request in master, with this fix.

Fabien

@Fafou
Copy link
Author

Fafou commented Oct 10, 2024

I think it can be related to this issue

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

1 participant