kerryjiang / WebSocket4Net

A popular .NET WebSocket Client
Apache License 2.0
764 stars 273 forks source link

Cannot send data unless an event is currently active #170

Open NateKomodo opened 4 years ago

NateKomodo commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

bPoller2810 commented 4 years ago

@NateKomodo did you find any relyable workaround?

NateKomodo commented 4 years ago

@bPoller2810 I switched library

bPoller2810 commented 4 years ago

@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.

NateKomodo commented 4 years ago

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