DEV Community

Cover image for The Trail That Went Cold: Debugging Silent Spring Boot RSocket Fragmentation Failures
Szymon Kaczorowski
Szymon Kaczorowski

Posted on Originally published at grupavii.eu AI-assisted

The Trail That Went Cold: Debugging Silent Spring Boot RSocket Fragmentation Failures

Originally published on The Trail by Grupa VII.

The message came late Wednesday afternoon: "No data is arriving."

Production. Customers paying hundreds per month for real-time data, data they use to make business decisions, were staring at stale dashboards. Our peer-to-peer RSocket mesh had gone silent.

Our customer success lead was already fielding calls. The CEO had pinged Slack twice. A Wednesday evening about to disappear into the void.

Green Health Checks While Customer Data Stopped

Monitoring dashboards showed healthy connections with services up, heartbeats flowing, and every metric green. But customers weren't getting their data.

Logs showed nothing: no errors, no warnings. Just successful health checks and the absence of actual payload messages. The connection was alive. The channel was open. Data was being sent. It vanished somewhere in between.

Hitting RSocket's 16MB Frame Limit in Debug Logs

I checked the RSocket protocol specification. Our implementation matched the examples. Request streams, bidirectional communication, peer-to-peer topology. All correct.

Hours of documentation, cross-referencing, staring at code that looked exactly like the examples. With INFO logs staying completely blank, I finally dropped logging to DEBUG and found it, hidden among thousands of routine lines:

CanceledException (0x203): The payload is too big to be send as a single frame
with a max frame length 16777215. Consider enabling fragmentation
Enter fullscreen mode Exit fullscreen mode

16,777,215 bytes (about 16 megabytes): the RSocket protocol's hard single-frame limit.

Our batch aggregation normally ran around 2MB, but after a busy day it had grown past the limit. Finally, a clue.

Why spring.rsocket.server.fragment-size Did Nothing

RSocket uses a 24-bit field for frame length, a hard protocol limit. For payloads over 16MB, you need fragmentation.

The Spring Boot docs showed the fix:

spring:
  rsocket:
    server:
      fragment-size: 1MB
Enter fullscreen mode Exit fullscreen mode

I deployed the fix and went home thinking the problem was solved.

The next morning it was still broken, with the same error and the same silent failure. The only new clue:

io.rsocket.exceptions.ConnectionErrorException: Connection closed unexpectedly
Enter fullscreen mode Exit fullscreen mode

The config was in place, the documentation followed to the letter, but it was still failing. The YAML looked correct, the IDE autocompleted it, and the docs said it should work.

Tracing @ConditionalOnProperty in RSocketServerAutoConfiguration

There's a moment in debugging when you realize the documentation isn't going to save you. When the official answer doesn't work and you have to dig deeper. I opened Spring Boot's RSocketServerAutoConfiguration source.

The entire server configuration class, the one that would read my fragment-size property, was wrapped in a conditional (excerpted):

// Excerpted from Spring Boot's RSocketServerAutoConfiguration
@ConditionalOnProperty("spring.rsocket.server.port")
@Configuration(proxyBeanMethods = false)
static class EmbeddedServerConfiguration {
    // ...
    map.from(properties.getServer().getFragmentSize())
       .to(factory::setFragmentSize);
    // ...
}
Enter fullscreen mode Exit fullscreen mode

And there it was.

We were running RSocket over WebSocket, sharing the HTTP port. spring.rsocket.server.port was never set. The entire configuration class was never loaded. My YAML property was being parsed, validated, and bound to RSocketProperties, yet never applied to the running server.

What to check: A Spring Boot property that parses cleanly and autocompletes in your IDE can still be dead at runtime. Inspect Spring Boot Actuator's /actuator/conditions report or write an integration test against the actual WebSocket transport to verify that the expected auto-configuration class is active.

Configuring Fragmentation Programmatically on Server and Client

The fix required bypassing the autoconfiguration entirely and configuring fragmentation programmatically on both peers:

@Configuration
class RSocketConfig {

    @Bean
    fun rSocketServerCustomizer() = RSocketServerCustomizer { server ->
        server.fragment(1024 * 1024)  // 1MB server-side fragments
    }

    @Bean
    fun rSocketConnectorConfigurer() = RSocketConnectorConfigurer { connector ->
        connector.fragment(1024 * 1024)  // 1MB client-side fragments
    }
}
Enter fullscreen mode Exit fullscreen mode

I deployed, and data flowed. The batch that had been failing for days went through cleanly. A handful of lines of code, after two days of hunting. The customer success lead could finally stop apologizing.

Wiring both RSocketServerCustomizer and RSocketConnectorConfigurer (or calling .rsocketConnector { it.fragment(1024 * 1024) } on RSocketRequester.Builder) ensures both peers fragment large payloads symmetrically without relying on conditional YAML paths that never activate over shared HTTP WebSocket ports.

WebSocket MTU caveat: Reactor Netty defaults to a 64 KB WebSocket maxFramePayloadLength, so when running RSocket over WebSocket either keep the RSocket fragment MTU at or below 65536 bytes or raise Netty's WebSocket frame limit (spring.rsocket.server.spec.max-frame-payload-length in Boot 3.2+ or a custom WebsocketServerSpec) to match.

You can reproduce this yourself: the companion repository includes tests that prove each stage (large batches failing without config, still failing with YAML config, and succeeding only with the programmatic fix).

Trade-Offs and What to Check on Monday

This bug illustrates a systemic risk in modern frameworks: validated configuration that silently doesn't apply, the same class of test-vs-production mismatch that slips through mocked PRs (Teaching the Trail). When a @ConditionalOnProperty gate quietly skips an auto-configuration class for your deployment topology, Spring Boot raises zero warnings at startup.

Enabling RSocket fragmentation is also a tactical fix with its own trade-off: reassembling 20MB+ fragmented frames buffers memory on both peers and introduces head-of-line pressure on multiplexed streams. If payloads regularly grow into tens of megabytes, treat fragmentation as a safety rail while moving the producer to bounded application-level chunking or streaming smaller records.

Before the next quiet Wednesday afternoon outage, check three things on Monday:

  1. Monitor customer-visible delivery, not only transport heartbeats. Pair liveness metrics with an alert on "zero business payloads delivered within N minutes" for active streams.
  2. Audit active conditions in staging. Pull /actuator/conditions (or equivalent DI/wiring diagnostics) after changing critical transport, pool, or timeout properties to confirm the target bean actually bound the setting.
  3. Test ceiling payloads against the real transport in CI. Run at least one integration test that pushes a >16MB batch across the actual WebSocket server port rather than an in-memory mock.

In 2-week architecture reviews and system architecture work, those deployment assumptions deserve the same scrutiny as service boundaries. Follow the trail from configuration to runtime behavior, and verify that a healthy connection is actually delivering the data customers depend on.


Dealing with silent production failures or framework surprises? Explore our fixed-scope 2-Week Architecture Review and System Architecture services, or share one bottleneck via the contact form.

Top comments (0)