m-expunged / guacamole-sharp

C# replacement of the Apache Guacamole server-side Java servlet.
Apache License 2.0
26 stars 3 forks source link

listener receive callback ArgumentOutOfRangeException #7

Closed m-expunged closed 2 years ago

m-expunged commented 2 years ago

Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'length')

at System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray[T](T[] array, Range range)

at GuacamoleSharp.Server.WebSocketHelpers.ReadFromFrames(Byte[] payload, Int32 receivedLength) in /src/GuacamoleSharp.Server/WebSocketHelpers.cs:line 70

at GuacamoleSharp.Server.GSListener.ReceiveCallback(IAsyncResult ar) in /src/GuacamoleSharp.Server/GSListener.cs:line 261

at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

--- End of stack trace from previous location ---

at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(ContextCallback callback, Object state, Task& currentTask)

--- End of stack trace from previous location ---

at System.Threading.Tasks.Task.<>c.b__128_1(Object state)

at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()

at System.Threading.ThreadPoolWorkQueue.Dispatch()

at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

at System.Threading.Thread.StartCallback()

m-expunged commented 2 years ago

Error while parsing broken websocket frame length? Something else? Almost never occurs and is hard to reproduce.

m-expunged commented 2 years ago

Exception did not pop up for a while now. Might have unintentionally fixed it during refactoring...

m-expunged commented 2 years ago

Might be mouse cursor position desync

https://github.com/m-expunged/guacamole-sharp/blob/bcb4edd2a15247af1b755f8d473d99bbb5f47e8c/GuacamoleSharp.Server/GSListener.cs#L298

m-expunged commented 2 years ago

"Fixed" by logging warning and skipping "broken" websocket frames. Will leave the issue open until a better fix comes to mind. Websocket frame skipping is not noticeable and doesnt impact performance negatively as far as i can tell