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.2k views Asked by Damian At
1
If we take a look to the
StompSubProtocolHandler
code, we'll see this:So, the
CONNECT
frame not only emitted as aSessionConnectEvent
, but is sent to theclientInboundChannel
as well.So, what you need to achieve you requirement is just providing a custom
ChannelInterceptor
withpreSend
implementation and register it overridingWebSocketMessageBrokerConfigurer.configureClientInboundChannel
.