Skip to content

Improve guidance in WebFlux on how to join inbound and outbound streams in WebSocketHandler #35572

@peter21adrian

Description

@peter21adrian

In the documentation, an example is provided for implementing WebSocketHandler when processing inbound and outbound messages as independent streams. It specifies using the Mono.zip() method, but this does not work as intended. Instead, Flux.merge() should be used.

Mono.zip() waits for all sources to emit a value before combining them, so if one stream only receives or only sends messages, it may not emit at all. In contrast, Flux.merge() emits as soon as any source emits, making it more suitable for joining independent streams.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: documentationA documentation task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions