Yellow-Dog-Man / Resonite-Issues

Issue repository for Resonite.
https://resonite.com
124 stars 2 forks source link

Websocket-Sharp Fatal Error #1199

Open VirgilCore opened 6 months ago

VirgilCore commented 6 months ago

Describe the bug?

for some time myself, DetectiveBot, and Climber have been having an issue with Websockets on headless servers. They randomly disconnect and throw an error

To Reproduce

  1. Start a Websocket connection
  2. periodically send messages to the websocket
  3. connection dies randomly and throws exception to console NOTE: This is Annoyingly hard to replicate

Expected behavior

websocket does not disconnect at random

Screenshots

No response

Resonite Version Number

2024.1.19.687

What Platforms does this occur on?

Windows, Linux

What headset if any do you use?

No response

Log Files

log files dont seem to show the error or some reason

bd12a4a4-3ecc-4e3d-8592-298ecb49f0a1 - 2024.1.19.687 - 2024-01-19 21_55_11.log

01/19/2024 21:23:35|Fatal|WebSocket.<startReceiving>b__176_2|WebSocketSharp.WebSocketException: The header of a frame cannot be read from the stream.at WebSocketSharp.WebSocketFrame.processHeader (System.Byte[] header) [0x00010] in <7de3ebfa4f374e6aaec939c3ef521f2f>:0at WebSocketSharp.WebSocketFrame+<>c__DisplayClass73_0.<readHeaderAsync>b__0 (System.Byte[] bytes) [0x00000] in <7de3ebfa4f374e6aaec939c3ef521f2f>:0at WebSocketSharp.Ext+<>c__DisplayClass48_0.<ReadBytesAsync>b__0 (System.IAsyncResult ar) [0x00085] in <7de3ebfa4f374e6aaec939c3ef521f2f>:0

01/19/2024 22:26:07|Fatal|WebSocket.<startReceiving>b__176_2|System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer. ---> System.Net.Sockets.SocketException: Connection reset by peer
                             --- End of inner exception stack trace ---
                            at System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.ThrowException (System.Net.Sockets.SocketError error) [0x00007] in <a8a996a78a804d888710c9e2575d78c8>:0 
                            at System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.GetResult (System.Int16 token) [0x00022] in <a8a996a78a804d888710c9e2575d78c8>:0 
                            at System.Threading.Tasks.ValueTask`1+ValueTaskSourceAsTask+<>c[TResult].<.cctor>b__4_0 (System.Object state) [0x00030] in <d636f104d58046fd9b195699bcb1a744>:0 
                          --- End of stack trace from previous location where exception was thrown ---

                            at Mono.Net.Security.MobileAuthenticatedStream.InnerRead (System.Boolean sync, System.Int32 requestedSize, System.Threading.CancellationToken cancellationToken) [0x00104] in <a8a996a78a804d888710c9e2575d78c8>:0 
                            at Mono.Net.Security.AsyncProtocolRequest.InnerRead (System.Threading.CancellationToken cancellationToken) [0x000ac] in <a8a996a78a804d888710c9e2575d78c8>:0 
                            at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x00093] in <a8a996a78a804d888710c9e2575d78c8>:0 
                            at Mono.Net.Security.AsyncProtocolRequest.StartOperation (System.Threading.CancellationToken cancellationToken) [0x0008b] in <a8a996a78a804d888710c9e2575d78c8>:0 
                            at Mono.Net.Security.MobileAuthenticatedStream.StartOperation (Mono.Net.Security.MobileAuthenticatedStream+OperationType type, Mono.Net.Security.AsyncProtocolRequest asyncRequest, System.Threading.CancellationToken cancellationToken) [0x0024b] in <a8a996a78a804d888710c9e2575d78c8>:0 
                            at System.Threading.Tasks.TaskToApm.End[TResult] (System.IAsyncResult asyncResult) [0x0002f] in <d636f104d58046fd9b195699bcb1a744>:0 
                            at System.Net.Security.SslStream.EndRead (System.IAsyncResult asyncResult) [0x00000] in <a8a996a78a804d888710c9e2575d78c8>:0 
                            at WebSocketSharp.Ext+<>c__DisplayClass48_0.<ReadBytesAsync>b__0 (System.IAsyncResult ar) [0x00000] in <7de3ebfa4f374e6aaec939c3ef521f2f>:0 

Additional Context

I found an issue on the websoket-sharp github repo that goes into detail about this bug.

Reporters

DetectiveBot, Climber

Nytra commented 6 months ago

Try to replicate it in a fresh grid world, because it might be a problem with the world you are in especially if it uses a culling system like I think that one does

VirgilCore commented 6 months ago

this happens in worlds without culling too

shiftyscales commented 6 months ago

If this issue is in a third-party dependency- then they would need to fix it on their end. I'd recommend contributing to the issue you linked/working with them to get it resolved, @VirgilCore.

VirgilCore commented 6 months ago

@shiftyscales that issue has been open since 2016 and someone in the issue came up with a fix for the problem but it still hasnt been fixed

VirgilCore commented 5 months ago

This issue is still happening on the latest version. The log file once again proves pretty useless.

VirgilCore commented 5 months ago

I looked into the issue a little more and supposedly the issue was fixed five years ago? But it still seems to be happening on Resonite. What version of websocket-sharp does FrooxEngine use?

ProbablePrime commented 5 months ago

Hello,

Have you read this guide: https://wiki.resonite.com/Troubleshooting:Websockets ? Additionally what server are you using for websockets? If possible please make the server code available.

Thank you.

VirgilCore commented 5 months ago

I have read that guide, yes. The database server uses ws on NodeJS.

VirgilCore commented 5 months ago

Here's a link to the code running on said database.

ProbablePrime commented 5 months ago

Thanks this helps!

We use WebsocketSharp 1.0.3-rc11 which is the latest WebsocketSharp version on Nuget.

With so many users using websockets for Heart Rate and other matters successfully on Resonite, it means that there has to be something about your setup that is different or strange to cause this and we just have to figure out what it is.

VirgilCore commented 5 months ago

I'm not the most experienced with the code on the database's end, since I had DetectiveBot make that part of the system. I'll let him know to come read this issue and you could work with him to find the problem