Handling WebSockets without SignalR in ASP.NET 4

Add this line to allow current connections to be accessed.

Send data from another event to trigger to all connected websockets

One last thing, you may also need to enable websockets if your on an older version of a project. Add or merge these params below into your system.web tag

And below is a sample of a test client form to use on Desktop machines to communicate with the server if needed, just update the URL to point to your source.

one thing to note, is when dealing with Websockets in this way you must avoid using .Wait on the main thread to prevent deadlocks. When the function itself is called it will halt on the first await command and never return. I think this is because the report data is being processed through the main message pump of the main thread and gets locked by using the wait() command. Its best to check the status in a loop with application.doevents and add a sleep if needed.

Other useful links on this topic I found:

https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_server

https://www.esegece.com/websockets/main-components/net-components/net-websocket-client

https://mcguirev10.com/2019/08/17/how-to-close-websocket-correctly.html

Use this if you’d like to connect with powershell!

Leave a comment

Your email address will not be published. Required fields are marked *