server icon indicating copy to clipboard operation
server copied to clipboard

Add KeepAliveMode option

Open Shane32 opened this issue 1 year ago • 1 comments

Adds a 'secure' keep-alive mode where:

  • A ping is sent on a timer from the last received pong
  • Ping messages carry a unique payload (random guid)
  • Received pong messages verify the payload
  • If a pong is not received with the correctly id in a timely fashion, the client is forcibly disconnected

Reason:

  • With subscriptions that continuously send lots of data, there is no way to determine if socket backpressure due to slow client connections is causing resource exhaustion. This feature will validate that buffers are drained over the specified time period, as the client would not know what id to send with a pong if it did not process the incoming messages fast enough.

Consider:

  • Name of KeepAliveMode enum values
  • Adding separate timer property that represents the amount of time to wait for a corresponding pong after a sent ping. Currently this just matches the ping timer.

Todo:

  • Add tests

Shane32 avatar Oct 07 '24 04:10 Shane32

Codecov Report

Attention: Patch coverage is 52.17391% with 55 lines in your changes missing coverage. Please review.

Project coverage is 89.06%. Comparing base (a84c553) to head (2141f56). Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
...NetCore/WebSockets/GraphQLWs/SubscriptionServer.cs 40.00% 42 Missing and 3 partials :warning:
...ts.AspNetCore/WebSockets/BaseSubscriptionServer.cs 71.42% 5 Missing and 3 partials :warning:
...ets/SubscriptionsTransportWs/SubscriptionServer.cs 75.00% 1 Missing and 1 partial :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1154      +/-   ##
==========================================
- Coverage   90.88%   89.06%   -1.82%     
==========================================
  Files          50       51       +1     
  Lines        2425     2543     +118     
  Branches      432      450      +18     
==========================================
+ Hits         2204     2265      +61     
- Misses        175      224      +49     
- Partials       46       54       +8     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Oct 27 '24 13:10 codecov-commenter