is there any way to intercept STOMP CONNECT frame in Spring and refuse it under some conditions?
The interception itself can be done using SessionConnectEvent but I would like to allow or refuse the connection based on headers. I cannot do it in the SessionConnectEvent listener.
Spring Websocket Stomp handle CONNECT frame
1.3k views Asked by Damian At
1
If we take a look to the
StompSubProtocolHandlercode, we'll see this:So, the
CONNECTframe not only emitted as aSessionConnectEvent, but is sent to theclientInboundChannelas well.So, what you need to achieve you requirement is just providing a custom
ChannelInterceptorwithpreSendimplementation and register it overridingWebSocketMessageBrokerConfigurer.configureClientInboundChannel.