❔ Connecting to Websockets in C#

Im currently following some online guides, but i cant seem to properly connect to my websocket, I have linked 2 images, 1 for the Socket Client and one for the Socket Server, the error im getting when trying to send a socket message to client, is something about the User Closing the Connection without proper Handshake, for socket Client i use WebSocket.Client and for Server i use standard ASP.NET
Client
Server Side
4 Replies
JakenVeina
JakenVeina10mo ago
setting aside your use of a thread-blocking signal inside an async method you returning the controller method is you instructing the HTTP response to terminate creating a WebSocket object and caching it doesn't extend the lifetime of the connection the lifetime of the connection is tied to the lifetime of the HttpContext, and the pipeline processing it don't return the Controller method until you're ready to close the connection
Somgör from Human Resources
yes, ive fixed it after noticing the socket lifespan only lasts for the current HttpContext
Accord
Accord10mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.