Im trying spring websockets and for some reason i dont understand, i can establish connection with the server but when i send data nothing happens.
Here is my Config class (exatcly equal to other spring websocket examples):
#Configuration
#EnableWebSocketMessageBroker
public class WebSocketsConfig extends AbstractWebSocketMessageBrokerConfigurer {
#Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/topic");
config.setApplicationDestinationPrefixes("/app");
}
#Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws").withSockJS();
}
}
My controller, in a package where i ensure that spring inicialites it, as i shee the init() message with the #PostConstruct annotation. As you see i wrote System.out.println to see in the console if the method triggers but this never happens, so data never gets to the controller:
#Controller
public class MonitorSpring {
#PostConstruct
protected void init() {
System.out.println("init()");
}
#MessageMapping("/sendmessage")
#SendTo("/topic/message")
public ChatMessage sendMessage(#Payload ChatMessage chatMessage) {
System.out.println("sendMessage here");
return chatMessage;
}
#MessageMapping("/adduser")
#SendTo("/topic/user")
public ChatMessage addUser(#Payload ChatMessage chatMessage, SimpMessageHeaderAccessor headerAccessor) {
System.out.println("addUser here");
headerAccessor.getSessionAttributes().put("username", chatMessage.getSender());
return chatMessage;
}
}
And finaly my JavaScript client, i will abbreviate putting only the important parts here:
function connect(event) {
username = document.querySelector('#name').value.trim();
if(username) {
usernamePage.classList.add('hidden');
chatPage.classList.remove('hidden');
var socket = new SockJS('https://' + document.location.host + '/ws');
stompClient = Stomp.over(socket);
stompClient.connect({}, onConnected, onError);
}
event.preventDefault();
}
function onConnected() {
stompClient.subscribe('/topic/message', onMessageReceived);
stompClient.subscribe('/topic/user', onMessageReceived);
stompClient.send("/app/adduser", {}, JSON.stringify({sender: username, type: 'JOIN'}))
connectingElement.classList.add('hidden');
}
function sendMessage(event) {
var messageContent = messageInput.value.trim();
if (messageContent && stompClient) {
var chatMessage = {
sender: username,
content: messageInput.value,
type: 'CHAT'
};
stompClient.send("/app/sendmessage", {}, JSON.stringify(chatMessage));
messageInput.value = '';
}
event.preventDefault();
}
I do connect and create the websocket without any problem, but when i send something to the server
i see this message in the chrome console but nothing happens on the server:
>>> SEND
destination:/app/sendmessage
content-length:53
{"sender":"user1","content":"message1","type":"CHAT"}
What could i be doing wrong?
First of all, you should implements WebSocketMessageBrokerConfigurer instead of AbstractWebSocketMessageBrokerConfigurer because is deprecated.
When you connect to the websocket
var socket = new SockJS('https://' + document.location.host + '/ws');
you should connect to the http endpoint
var socket = new SockJS('http://' + document.location.host + '/ws');
If you trying to send message to the https and dont have the certificates configured it might reject your messages.
Not sure if someone still facing these issues.
For anyone in the future
In addition to TOvidiu's answer, you should allow cross-origin header
registry.addEndpoint("/ws").setAllowedOrigins("*").withSockJS();
I will try to help you, I have a chat application, where user can not just chat also can upload images, even bookings using the spring and stomp, as I can check your code, I cant finally get the right issue with it but if you accept from me I can suggest some small changes wish that can be helpful to solve your issue.
for
#Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws").withSockJS();
}
can you change it to something like this?
#Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/chat").setAllowedOrigins("*").withSockJS();
}
and edition with the connection to stomp in JS
var socket = new SockJS('https://' + document.location.host + '/ws');
stompClient = Stomp.over(socket);
can you use this code?
function connectToChat(userName) {
let socket = new SockJS(url + '/chat');
console.log("socket.name", socket.name)
console.log("WebSocket.name", WebSocket.name)
stompClient = Stomp.over(socket);
console.log("stompClient = ", stompClient)
stompClient.connect({}, function (frame) {
console.log('Connected: ' + frame);
successCallback(userName);
}, () => {
reconnect(url, successCallback, userName);
});
}
function successCallback(userName) {
stompClient.subscribe("/topic/messages/" + userName, function (response) {
let data = JSON.parse(response.body);
console.log("data ", data);
if (selectedUser === data.to) {
render(data.message, data.from);
}
});
}
function reconnect(socketUrl, successCallback, userName) {
let connected = false;
let reconInv = setInterval(() => {
//let socket = new WebSocket(url +'/chat')
let socket = new SockJS(url + '/chat');
stompClient = Stomp.over(socket);
stompClient.connect({}, (frame) => {
clearInterval(reconInv);
connected = true;
successCallback(userName);
}, () => {
if (connected) {
reconnect(socketUrl, successCallback, userName);
}
});
}, 3000);
}
make sure that your link is the right one, for my code, I'm using
let socket = new SockJS(url + '/chat');
regarding HTTP or HTTPS if you are using stomp, it will understand if the link is with SSL or not.
finally, the first user must connect to the second user but in your case, you have 2 links
stompClient.subscribe('/topic/message', onMessageReceived);
stompClient.subscribe('/topic/user', onMessageReceived);
solve this issue so the socket can understand to which user to connect and send the message from the chat.
Wish I was helpful and wish that you can solve your issue.
finally, let me show you the exact configuration for the links to connect
#Configuration
#EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
#Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/chat").setAllowedOrigins("*").withSockJS();
}
#Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.setApplicationDestinationPrefixes("/app").enableSimpleBroker("/topic");
}
}
try this
var socket = new SockJS('/ws');
this worked for me
Related
This is about a spring boot + angularjs web application which uses websocket + stompjs to send push notifications.
I upgraded from Spring boot 1.2.0 to 2.1.3 recently. Before this upgrade websocket (push notifications) was working fine for couple of years.
I just upgraded spring boot and websocket related code remains exactly same, but it is not working now.
Not working means:
Below line executed at server side without any error/exception.
simpMessagingTemplate.convertAndSend("/topic/notify", payload);
Chrome debugger receives only "h" (heartbeat) but not the actual message.
I have no clue because,
server side code executed successfully till the last line.
websocket session established, I can get heartbeat messages, but no error at client side as well.
Code (but this same code works well with Spring boot 1.2.0:
1. Config:
#Configuration
#EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
#Value("${server.sessionTimeout}")
long sessionTimeoutInSecs;
#Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/topic");
config.setApplicationDestinationPrefixes("/app");
}
#Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/notify").withSockJS();
}
#Bean
public ServletServerContainerFactoryBean createWebSocketContainer() {
ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
// in milliseconds
container.setMaxSessionIdleTimeout(sessionTimeoutInSecs * 1000);
return container;
}
}
2. Message sending code:
simpMessagingTemplate.convertAndSend("/topic/notify", payload);
3. Client code:
(function() {
myApp.factory('autoUpdateTasksService', function($resource, $q, $log) {
var initSockets, notify, reconnect, socket, _callback;
_callback = null;
socket = {
client: null,
stomp: null
};
initSockets = function() {
socket.client = new SockJS('/notify');
socket.stomp = Stomp.over(socket.client);
socket.stomp.connect({}, function() {});
socket.client.onopen = function() {
var subscription1;
subscription1 = socket.stomp.subscribe("/topic/notify", notify);
//$log.log('socket connected');
};
};
reconnect = function() {
setTimeout(initSockets, 1000);
};
notify = function(message) {
try{
var taskNotifyObject;
if (message.body) {
taskNotifyObject = angular.fromJson(message.body);
//$log.log(taskNotifyObject);
var notificationArray=[];
notificationArray.push(taskNotifyObject);
_callback(notificationArray);
} else {
//$log.log("empty message");
}
} catch(e){
// alert(e.message);
}
};
return {
init: function(callback) {
_callback = callback;
initSockets();
}
};
});
}).call(this);
Is anything changed in spring framework between versions?
How I can debug/find where the message is lost?
Rootcause: AFTER the upgrade, the code in my question was failed to create connection between server and client ( failed to created websocketSession).
Changing code as below solves the problem, but I am NOT sure why this solution is working,
if anyone explains why this solution is working, It would be a great help.
1. Config:
#Configuration
#EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
#Value("${server.servlet.session.timeout}")
long sessionTimeoutInSecs;
#Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/queue");
config.setApplicationDestinationPrefixes("/app");
}
#Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/notify").addInterceptors(new HttpSessionHandshakeInterceptor());
}
#Bean
public ServletServerContainerFactoryBean createWebSocketContainer() {
ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
// in milliseconds
container.setMaxSessionIdleTimeout(sessionTimeoutInSecs * 1000);
return container;
}
/**
* DefaultSimpUserRegistry is the replacement of MySessionRegistry ( Custom UserSessionRegistry ) after upgrade to Spring 5.
* Below required with Spring 4.
* import org.springframework.messaging.simp.user.UserSessionRegistry;
#Repository
public class MySessionRegistry implements UserSessionRegistry, ApplicationListener<AbstractSubProtocolEvent> {
*
*/
#Bean
public DefaultSimpUserRegistry defaultSimpUserRegistry() {
DefaultSimpUserRegistry userRegistry = new DefaultSimpUserRegistry();
return userRegistry;
}
}
2. Message sending code:
import org.springframework.web.socket.messaging.DefaultSimpUserRegistry;
#Autowired
DefaultSimpUserRegistry defaultSimpUserRegistry;
.....
SimpUser simpUser = defaultSimpUserRegistry.getUser(payload.getUserName());
if(simpUser != null && simpUser.hasSessions()) {
template.convertAndSendToUser(payload.getUserName(), "/queue/notify", payload);
}
3. Client code:
(function() {
myApp.factory('autoUpdateTasksService', function($resource, $q, $log) {
var initSockets, notify, reconnect, socket, _callback;
_callback = null;
socket = {
client: null,
stomp: null
};
getContextPath = function() {
return window.location.pathname.substring(0, window.location.pathname.indexOf("/",2));
};
initSockets = function() {
//socket.addr = "wss://" + window.location.host + "/notify";
socket.addr = ((window.location.protocol && (window.location.protocol.indexOf("https") >= 0)) ? "wss://" : "ws://") + window.location.host + getContextPath() + "/notify";
socket.client = Stomp.client(socket.addr); //new SockJS('/notify');
socket.client.connect({}, function () {
$log.log("Connected to websocket through " + socket.addr);
socket.client.subscribe("/user/queue/notify", notify);
}, function (err) {
$log.log("Error when connection to websocket " + socket.addr + ".\n" + err);
});
};
How I can debug/find where the message is lost?
To validate client-server connectivity ( or creation of websocketSession), I added below listener.
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.web.socket.messaging.SessionConnectedEvent;
import org.springframework.web.socket.messaging.SessionSubscribeEvent;
#Component
public class WebSocketListener implements ApplicationListener <ApplicationEvent> {
//WebSocket session created
if (appEvent instanceof SessionConnectedEvent){
StompHeaderAccessor sha = StompHeaderAccessor.wrap(((SessionConnectedEvent) appEvent).getMessage());
logger.info("SessionConnectedEvent: STOMP WebSocket session created for the user: {}", sha.getUser().getName());
}
//subscribed to websocketSession
if (appEvent instanceof SessionSubscribeEvent){
StompHeaderAccessor sha = StompHeaderAccessor.wrap(((SessionSubscribeEvent) appEvent).getMessage());
logger.info("SessionSubscribeEvent: User {} subscribed to WebSocket session, destination: {}", sha.getUser().getName(), sha.getDestination());
}
//
// if (appEvent instanceof BrokerAvailabilityEvent){
// logger.info("BrokerAvailabilityEvent: {}", appEvent.toString());
// }
}
}
I'm new to Spring and this maybe a basic task but after I've set up spring boot with stomp websocket, an interactive web page is accomplished and I can push a json object to a client webpage but my goal is to refresh the client/user's page only, I don't need a json transfer.
I just want to refresh the user's page after admin has logged him out.
this is my app.js
var stompClient = null;
function setConnected(connected) {
$("#connect").prop("disabled", connected);
$("#disconnect").prop("disabled", !connected);
if (connected) {
$("#conversation").show();
} else {
$("#conversation").hide();
}
$("#greetings").html("");
}
function connect() {
var socket = new SockJS('/vira-websocket');
stompClient = Stomp.over(socket);
stompClient.connect({}, function (frame) {
setConnected(true);
stompClient.subscribe('/topic/greetings', function (greeting) {
showGreeting(JSON.parse(greeting.body).content);
});
});
}
function disconnect() {
if (stompClient !== null) {
stompClient.disconnect();
}
setConnected(false);
}
function sendName() {
stompClient.send("/app/hello", {}, JSON.stringify({'name': $("#name").val()}));
}
$(function () {
$( "form" ).on('submit', function (e) {e.preventDefault();});
$( "#connect" ).click(function() { connect(); });
$( "#disconnect" ).click(function() { disconnect(); });
$( "#send" ).click(function() { sendName(); });
});
my config
#Configuration
#EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
#Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/topic");
config.setApplicationDestinationPrefixes("/app");
}
#Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/vira-websocket").withSockJS();
}
}
and controller
#Controller
public class GreetingController {
#MessageMapping("/hello")
#SendTo("/topic/greetings")
public Greeting greeting(HelloMessage message) throws Exception {
Thread.sleep(3000); // simulated delay
return new Greeting("Hello, " + message.getName() + "!");
}
}
I'm not sure I fully understand your question but if you want to refresh the page instead of pushing a json just replace location.reload(); with the callback of subscribe function which is the second argument.
function connect() {
var socket = new SockJS('/vira-websocket');
stompClient = Stomp.over(socket);
stompClient.connect({}, function (frame) {
setConnected(true);
stompClient.subscribe('/topic/greetings', location.reload());
});
}
according to the documentation The client will send a STOMP
SUBSCRIBE frame to the server and register the callback. Every time
the server send a message to the client, the client will in turn call
the callback with a STOMP Frame object corresponding to the message:
which means your refresh will be called after you sent a push to the subscribed users.
I have the following Vertx Route setup:
router.post("/api/apple/")
.handler(e -> {
e.response()
.putHeader("content-type", "application/json")
.setStatusCode(200)
.end("hello");
})
.failureHandler(ctx -> {
LOG.error("Error: "+ ctx.response().getStatusMessage());
ctx.response().end();
});
vertx.createHttpServer().requestHandler(router::accept)
.listen(config().getInteger("http.port", 8081), result -> {
if (result.succeeded()) {
LOG.info("result succeeded in my start method");
future.complete();
} else {
LOG.error("result failed");
future.fail(result.cause());
}
});
When I call this from my Java test client:
Async async = context.async();
io.vertx.core.http.HttpClient client = vertx.createHttpClient();
HttpClientRequest request = client.post(8081, "localhost", "/api/apple/", response -> {
async.complete();
LOG.info("Some callback {}",response.statusCode());
});
String body = "{'username':'www','password':'www'}";
request.putHeader("content-length", "1000");
request.putHeader("content-type", "application/x-www-form-urlencoded");
request.write(body);
request.end();
The client keeps running and then the client times out. Seems like it is not able to find the endpoint on localhost:8081/api/apple
You didn't deploy your verticle defining routes in the test scope. Here is a working snippet:
public class HttpServerVerticleTest extends VertxTestRunner {
private WebClient webClient;
private HttpServerVerticle httpServer;
private int port;
#Before
public void setUp(TestContext context) throws IOException {
port = 8081;
httpServer = new HttpServerVerticle(); // the verticle where your routes are registered
// NOTICE HERE
vertx.deployVerticle(httpServer, yourdeploymentOptions, context.asyncAssertSuccess());
webClient = WebClient.wrap(vertx.createHttpClient());
}
#After
public void tearDown(TestContext testContext) {
webClient.close();
vertx.close(testContext.asyncAssertSuccess());
}
#Test
public void test_my_post_method(TestContext testContext) {
Async http = testContext.async();
String body = "{'username':'www','password':'www'}";
webClient.post(port, "localhost", "/api/apple/")
//.putHeader("Authorization", JWT_TOKEN)
.putHeader("content-length", "1000");
.putHeader("content-type", "application/x-www-form-urlencoded");
.sendJson(Buffer.buffer(body.getBytes()), requestResponse -> {
if (requestResponse.succeeded()) {
testContext.assertTrue(requestResponse.result().statusCode() == HttpResponseStatus.OK.code());
testContext.assertTrue(requestResponse.result().body().getString().equals("hello"));
} else {
testContext.fail(requestResponse.cause());
}
http.complete();
});
}
}
i have a MVC asp.net web app.
It is hosted on my local network on a Windows 8.1 32bit OS.
I have found that SignalR only supports 1 client connection.
So, I removed SignalR and switched to web sockets.
However, this did not solve the problem.
Am I accurate in stating that Web Sockets only supports 1 client connection on this OS and IIS 8 Client?
Is the solution to use IIS Express because I had problems getting this to work and in the end ended up rebuilding my PC.
Is there no workaround for this issue?
This is my code:
In my Global.cs file:
public static WebSocketCollection clients = new WebSocketCollection();
In my handler:
public class MicrosoftWebSockets : WebSocketHandler
{
private string name;
public override void OnOpen()
{
this.name = this.WebSocketContext.QueryString["chatName"];
MvcApplication.clients.Add(this);
//clients.Broadcast(name + " has connected.");
}
public void SendImage(byte[] jpeg)
{
this.Send(jpeg);
}
public override void OnMessage(string message)
{
MvcApplication.clients.Broadcast(string.Format("{0} said: {1}", name, message));
}
public override void OnClose()
{
MvcApplication.clients.Remove(this);
MvcApplication.clients.Broadcast(string.Format("{0} has gone away.", name));
}
}
In my HTML page:
var conversation = $('conversation');
var url = 'ws://192.168.0.13:80/SocketHandler.ashx?name=John Doe';
ws = new WebSocket(url);
ws.binaryType = 'arraybuffer';
ws.onerror = function (e) {
$('#divSystemMessage').html('Problem with connection: ' + e.message);
};
ws.onopen = function () {
$('#divSystemMessage').html('Client connected');
};
ws.onmessage = function (e) {
liveViewIndex = 0;
desktopImage.src = 'data:image/jpeg;base64,' + base64ArrayBuffer(e.data);
};
ws.onclose = function () {
$('#divSystemMessage').html('Closed connection!');
};
public class SocketHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
if (context.IsWebSocketRequest)
context.AcceptWebSocketRequest(new MicrosoftWebSockets());
}
public bool IsReusable
{
get
{
return false;
}
}
}
I'm developing a realtime notification system through WebSockets by using Spring 4.
The source code is as follows:
WebSocketConfig:
#Configuration
#EnableScheduling
#EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
#Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/lrt").withSockJS();
}
#Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.enableSimpleBroker("/queue/", "/topic/");
registry.setApplicationDestinationPrefixes("/app");
}
}
LRTStatusListener:
#Service
public class LRTStatusListener implements ApplicationListener<BrokerAvailabilityEvent>{
private static final Logger LOG = LoggerFactory.getLogger(LRTStatusListener.class);
private final static long LRT_ID = 1234567890;
private final static String LRT_OWNER = "Walter White";
private final LRTStatusGenerator lrtStatusGenerator = new LRTStatusGenerator(LRT_ID, LRT_OWNER);
private final MessageSendingOperations<String> messagingTemplate;
private AtomicBoolean brokerAvailable = new AtomicBoolean();
#Autowired
public LRTStatusListener(MessageSendingOperations<String> messagingTemplate) {
this.messagingTemplate = messagingTemplate;
}
#Override
public void onApplicationEvent(BrokerAvailabilityEvent event) {
this.brokerAvailable.set(event.isBrokerAvailable());
}
#Scheduled(fixedDelay=2000)
public void sendLRTStatus() {
LRTStatus lrtStatus = this.lrtStatusGenerator.generateLRTStatus();
if (LOG.isTraceEnabled())
LOG.trace("Sending LRT status");
if (this.brokerAvailable.get())
this.messagingTemplate
.convertAndSend("/topic/status" + lrtStatus.getLRTId(), lrtStatus);
}
// Random status generator
private static class LRTStatusGenerator {
private LRTStatus lrtStatus;
public LRTStatusGenerator(long lrtId, String owner) {
lrtStatus = new LRTStatus(lrtId, owner, getCurrentTimestamp(), generateLRTStatusMessage());
}
public LRTStatus generateLRTStatus() {
lrtStatus.setMessage(generateLRTStatusMessage());
return lrtStatus;
}
private String getCurrentTimestamp() {
Date date = new Date();
Timestamp timestamp = new Timestamp(date.getTime());
return timestamp.toString();
}
private String generateLRTStatusMessage() {
String statusMessage;
switch ((int) Math.random() * 2) {
case 1:
statusMessage =
"HANK: What? You want me to beg? You're the smartest guy I ever met. " +
"And you're too stupid to see... he made up his mind ten minutes ago.";
break;
case 2:
statusMessage =
"WALTER: That's right. Now say my name. " +
"- DECLAN: ...You're Heisenberg. - WALTER: You're goddamn right.";
break;
default:
statusMessage =
"WALTER: I am not in danger, Skyler. I am the danger! " +
"A guy opens his door and gets shot and you think that of me? " +
"No. I am the one who knocks!";
break;
}
return statusMessage;
}
}
}
CheckLRTStatusController
#Controller
public class CheckLRTStatusController {
#MessageExceptionHandler
#SendToUser("/topic/errors")
public String handleException(Throwable exception) {
return exception.getMessage();
}
}
The application simulates the status of a long running transaction (LRT), by changing its info every 2000ms.
Now, I'm testing the WebSocket by defining a client via SockJS:
<script src="http://cdn.sockjs.org/sockjs-0.3.min.js"></script>
<script>
var sock = new SockJS('/lrt');
sock.onopen = function() {
console.log('open');
};
sock.onmessage = function(e) {
console.log('message', e.data);
};
sock.onclose = function() {
console.log('close');
};
</script>
The connection works fine, but I'm unable to see the data stream.
How can I properly configure my application in order to produce and then route on my client's console the messages sent by the WebSocket Server?
Note that I'm also using a build-in Message Broker with the aim to manage the message queue.
Is this the only JavaScript code you currently have?:
<script src="http://cdn.sockjs.org/sockjs-0.3.min.js"></script>
<script>
var sock = new SockJS('/lrt');
sock.onopen = function() {
console.log('open');
};
sock.onmessage = function(e) {
console.log('message', e.data);
};
sock.onclose = function() {
console.log('close');
};
</script>
That only sets up the connection with fallback on SockJS but you are not subscribing to the message broker. You need to do that too.
In your current setup you have:
registry.enableSimpleBroker("/queue/", "/topic/");
You need to create a JavaScript STOMP client (over SockJS) that subscribes for those, something like:
stompClient.subscribe("/topic/status*", function(message) {
...
});
stompClient.subscribe("/queue/whatever", function(message) {
...
});
Have a look at the spring-websocket-portfolio application for a complete working example.