WebSocket4Net icon indicating copy to clipboard operation
WebSocket4Net copied to clipboard

Cannot send data unless an event is currently active

Open NateKomodo opened this issue 5 years ago • 6 comments

When trying to call websocket.Send() from anywhere else other than a subscribed event (When it is called) the data is not sent. The data is sent fine if i am calling the method from inside the DataRecievedEvent, but not anywhere other than a method.

NateKomodo avatar Mar 05 '20 19:03 NateKomodo

I have found a temporary workaround, if i Thread.sleep an event and then try sending from another thread, it works, because umm, code?

Although this also blocks the entire websocket

NateKomodo avatar Mar 05 '20 19:03 NateKomodo

If there is no event running at the same time ws.Send is called, ws.Send hangs forever

NateKomodo avatar Mar 05 '20 20:03 NateKomodo

@NateKomodo did you find any relyable workaround?

bPoller2810 avatar Mar 19 '20 11:03 bPoller2810

@bPoller2810 I switched library

NateKomodo avatar Mar 19 '20 14:03 NateKomodo

@NateKomodo sorry if i have to bother you again. i may have a few questions what environment you used. was yours a wpf/winforms or xamarin app? did if work at any point before? what did you think could have caused that it stopped working? what lib did you choose then?

i am facing the same problem right now.

bPoller2810 avatar Mar 20 '20 08:03 bPoller2810

I was using a .NET framework app I was running through mono, never worked before. I imagine the cause is a race condition, scoping issue, or poor design/bug that has resulted in data being unable to be sent while an event instance is not invoking. I believe I switched to a library called Extensions.WebSockets that I found on nuget, as it supported self signed certificates

NateKomodo avatar Mar 20 '20 09:03 NateKomodo