I\'m playing around with the new (as of version 4.2) java STOMP client support. My starting point is the getting started guide (Using WebSocket to build an interactive web appl
The following configuration works:
RequestUpgradeStrategy upgradeStrategy = new TomcatRequestUpgradeStrategy();
registry.addEndpoint("/hello")
.withSockJS();
registry.addEndpoint("/hello")
.setHandshakeHandler(new DefaultHandshakeHandler(upgradeStrategy))
.setAllowedOrigins("*");
Not sure if this is by design (i.e. two endpoints with the same path)?
A better solution based on Brian-Clozel's feedback is to use the java SockJsClient as a transport when configuring the WebSocketStompClient:
List transports = new ArrayList<>(1);
transports.add(new WebSocketTransport( new StandardWebSocketClient()) );
WebSocketClient transport = new SockJsClient(transports);
WebSocketStompClient stompClient = new WebSocketStompClient(transport);
which allows the use of only one endpoint to which the java and javascript clients can both connect:
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/hello").withSockJS();
}