How to receive PING and send PONG to keep-alive Websocket stream?

Helo everyone!
I have some issues while my Websocket stream works, it disposed after few time.
I have read the technical documentation and there write that need to use ping and pong.

My soft written on C# WPF, how I can get ping from and send pong to keep-alive connection?

If someone has an idea I’ll appreciated.


I suggest using ASP.NET Core as it handles the standard ping/pong format, as described in this document: RFC 6455 - The WebSocket Protocol

As explained in the documentation, the server sends a ping every 3 minutes. To handle this, you should capture the payload from the received ping and include it in the pong you send back to the server. Explore how ASP.NET Core manages incoming messages.