Search code examples
asp.net-corewebsocketpingasp.net-core-2.1pong

asp.net core websocket how many times ping fail will be closed


in asp.net core 2.1, websocket middleware has a property KeepAliveInterval, to send "ping" and receive "pong" from client to keep connection alive. But i can not found how many times when the server send "ping" faild (can not receive "pong") and would close the websocket connection? any one know?


Solution

  • .net core websocket is not handle the received pong frames. see: https://github.com/dotnet/corefx/blob/26445fd56e5abae36f4bd25d3fbe879fb88525d7/src/Common/src/System/Net/WebSockets/ManagedWebSocket.cs -> HandleReceivedPingPongAsync method.