LiveOrDevTrying / WebsocketsSimple

WebsocketsSimple provides an easy-to-use and customizable Websocket Server and Websocket Client. The server is created using a TcpListener and upgrades a successful connection to a WebSocket. The server and client can be used for non-SSL or SSL connections and authentication (including client and server SSL certification validation) is provided for identifying the clients connected to your server. Both client and server are created in .NET Standard and use async await functionality.
Apache License 2.0
21 stars 2 forks source link

CPU Usage on connect #2

Closed Slacquer closed 2 years ago

Slacquer commented 2 years ago

Hello, love the project, however upon creating a very simple implementation, when a client connects (not listening to event, not sending and data etc, literally just connected and nothing else) the cpu usage is quite high. After looking at the code, code you please add the following to your next version

await Task.Delay(1); In the WebsocketsSimple.Server-> Handlers -> WebsocketHandler.StartReceivingMessagesAsync just after the line while (connection.Client.Connected)

I did this locally and all was perfectly fine, in fact I could then connect a few hundred clients without much of an issued.

LiveOrDevTrying commented 2 years ago

This is a great fix! Ty! I have updated the library and new packages are being built. Well done!