I have a spring boot rsocket implementation where if a client cancels or closes their rsocket request then I want to cancel other subscription registrations on the server.
In the logs on the spring boot server I can see that a cancel message is sent or received:
WARN i.r.t.n.s.WebsocketServerTransport$1 [reactor-http-nio-3] received WebSocket Close Frame - connection is closing
INFO r.u.Loggers$Slf4JLogger [reactor-http-nio-3] cancel()
How do I capture and handle this cancel signal?
I tried cancel endpoints but these don't capture the signal:
@MessageMapping("cancel")
Flux<Object> onCancel() {
log.info("Captured cancel signal");
}
or
@ConnectMapping("cancel")
Flux<Object> onCancel2() {
log.info("Captured cancel2 signal");
}
This question on cancel subscriptions is possibly related, and this question on detecting websocket disconnection