@Slf4j
@Configuration
public class WebSocketConnectListener implements ApplicationListener<SessionConnectEvent> {
    @Override
    public void onApplicationEvent(SessionConnectEvent event) {
        StompHeaderAccessor wrap = StompHeaderAccessor.wrap(event.getMessage());
        String jwtToken = wrap.getFirstNativeHeader("Authorization");
        // check jwtToken...
        // if this check fails, I want to close the websocket connection, but I don't know how to close it?
    }
}

I want an example of closing a WebSocket connection. Thank you in advance for your answers.

Comment From: snicoll

Please do not cross post as it is wasting time for everybody