Skip to content

Fix server sending unnecessary proactive keepalives#1130

Open
wdroste wants to merge 1 commit intorsocket:masterfrom
brinqa:fix/1128-server-keepalive
Open

Fix server sending unnecessary proactive keepalives#1130
wdroste wants to merge 1 commit intorsocket:masterfrom
brinqa:fix/1128-server-keepalive

Conversation

@wdroste
Copy link

@wdroste wdroste commented Feb 17, 2026

Summary

  • Fixes Server initiates unnecessary keep-alives exactly after client keep-alives #1128
  • The server was incorrectly using ClientKeepAliveSupport which sends proactive KEEPALIVE frames with the Respond flag on a timer. Per the RSocket protocol, the server should only respond to client-initiated keepalives, never initiate its own.
  • Added ServerKeepAliveSupport that only monitors for keepalive timeout (detecting client disappearance) without sending proactive keepalive frames
  • RSocketServer now uses ServerKeepAliveSupport on the server side instead of ClientKeepAliveSupport

Changes

  • KeepAliveSupport.java - Added ServerKeepAliveSupport inner class whose onIntervalTick() only calls tryTimeout() (no frame sending)
  • RSocketRequester.java - Added constructor overload with serverSide boolean to select the appropriate keepalive support
  • RSocketServer.java - Passes serverSide=true when constructing RSocketRequester
  • KeepAliveTest.java - 4 new tests verifying server keepalive behavior

Test plan

  • Server does NOT send proactive keepalives with respond=true
  • Server still responds correctly to client keepalives
  • Server still detects keepalive timeout when client disappears
  • Server stays alive when client keepalives are present
  • All 739 rsocket-core tests pass (0 failures)

🤖 Generated with Claude Code

The server was incorrectly using ClientKeepAliveSupport which sends
proactive KEEPALIVE frames with the Respond flag. Added ServerKeepAliveSupport
that only monitors for timeout without initiating keepalives, per the
RSocket protocol specification.

Changes:
- Added ServerKeepAliveSupport inner class to KeepAliveSupport whose
  onIntervalTick() only calls tryTimeout() without sending frames
- Added serverSide parameter to RSocketRequester constructor to select
  the appropriate KeepAliveSupport implementation
- Updated RSocketServer to pass serverSide=true when creating the
  RSocketRequester
- Added tests verifying server does not send proactive keepalives,
  still responds to client keepalives, and still detects timeout

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server initiates unnecessary keep-alives exactly after client keep-alives

1 participant

Comments