Nhowka / Elmish.Bridge

Create client-server Fable-Elmish apps keeping a single mindset
MIT License
139 stars 17 forks source link

WebSocket is invalid State #47

Closed leolorenzoluis closed 2 years ago

leolorenzoluis commented 2 years ago

I get the following when I reload the page with websockets with Chrome.

Unhandled exception. System.AggregateException: One or more errors occurred. (The WebSocket is in an invalid state ('Closed') for this operation. Valid states are: 'Open, CloseReceived')
 ---> System.Net.WebSockets.WebSocketException (0x80004005): The WebSocket is in an invalid state ('Closed') for this operation. Valid states are: 'Open, CloseReceived'
   at System.Net.WebSockets.WebSocketValidate.ThrowIfInvalidState(WebSocketState currentState, Boolean isDisposed, WebSocketState[] validStates)
   at System.Net.WebSockets.ManagedWebSocket.SendAsync(ReadOnlyMemory`1 buffer, WebSocketMessageType messageType, WebSocketMessageFlags messageFlags, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at Microsoft.FSharp.Control.AsyncPrimitives.Start@1078-1.Invoke(ExceptionDispatchInfo edi) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1078
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 104
   at <StartupCode$FSharp-Core>.$Async.clo@181-16.Invoke(Object o) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 183
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
   at System.Threading.Thread.StartCallback()
[16:52:00 INF] HTTP GET /socket responded 101 in 255.8078 ms

Is this just a simple check before the library calls SendAsync to the WebSocket if it's in valid state?

Nhowka commented 2 years ago

Version 6.0.3 of Elmish.Bridge.Giraffe makes a check if the state is valid before sending.