sta/websocket-sharp

is websocket-sharp very slow?

barpas opened this issue · 3 comments

barpas commented

hi (sory my english)
i made some test: i connect to chrome dev tools listening on port 9222 by two dll's - websocketsharp and websocket4net - both ask chrome the same questions and get the same answers but websocket4net use 1,6 second for complete all tests and websocketsharp 25s !!!
any idea what may be a problem ?

public string SendCmd(string cmd)
{
	string message = "";
	using (var ws = new WebSocketSharp.WebSocket(this.sessionWSEndpoint))
	{
		ws.OnMessage += (sender, e) =>
		{
			message = e.Data;
		};
		ws.OnError += (sender, e) =>
		{
			message = e.Message;
		};
		ws.OnOpen += (sender, e) =>
		
			ws.Send(cmd);

		ws.OnClose += (sender, e) =>
		{
			//message = string.Format("code {0},reason {1}", e.Code, e.Reason);
		};
		ws.Connect();
		while (message == "")
		{
			System.Threading.Thread.Sleep(10);
		}
	}
	return message;
}

@barpas have you found the reason?

barpas commented

sory i wrote own implementation, very simple but a bit faster that websocket4net

Yes, this library is in fact slow and most likely outdated. I had issues running the server with mono, was able to only handle a very low and very random number of clients, sometimes 12, sometimes 28, sometimes 47, sometimes 77.
So I had to replace this with another server solution, specifically vtorola.websockets, it can handle 350 connections with no problems now.