Actually using some workarounds you can achieve what you want.
For that you should do:
- Use java configuration (not sure if it is possible with XML config)
- Extend your config class from WebSocketMessageBrokerConfigurationSupport and implement WebSocketMessageBrokerConfigurer interface
- Create custom sub-protocol websocket handler and extend it from SubProtocolWebSocketHandler class
- In your custom sub-protocol websocket handler override afterConnectionEstablished method and you will have access to WebSocketSession 🙂
I’ve created sample spring-boot project to show how we can disconnect client session from server side:
https://github.com/isaranchuk/spring-websocket-disconnect