Reputation: 225
I have a node app with sockjs sockets.
Some HTML / JS clients use stomp over sock JS but I don't understand how subscription works :
$scope.initSockets = function() {
$scope.socket.client = new SockJS('http://localhost:8080/websockets'); => WORKS
$scope.socket.stomp = Stomp.over($scope.socket.client);
$scope.socket.stomp.connect({}, function() {
$scope.socket.stomp.subscribe("/topic", $scope.notify); => NOTIFY Is never called
});
$scope.socket.client.onclose = $scope.reconnect;
};
Clients are connected, events are logged but $scope.notify is never called. How can we configure topic subscription ?
Edit :
Note sure I'm clear.
I'm using sockjs module as a websocket server.
There's not a lot of configuration :
echo.installHandlers(server, {prefix:'/websockets'});
// on new connection event
echo.on('connection', function(conn) {
console.log('New client connected : ' + conn.id);
// add this client to clients object
clients[conn.id] = conn;
// on connection close event
conn.on('close', function() {
console.log('Client disconnected ' + conn.id);
delete clients[conn.id];
});
});
Clients use stomp protocol over sockJS client.
They receive messages (regards to client logs), but their are not related to "topic" and are not parsed.
I don't understand how subscription works and how to configure it with sockjs on server side.
Upvotes: 3
Views: 3114
Reputation: 1678
Subscription works based on the destination. Default pattern is /exchange/routingkey
In your case it is /topic/notify
which means your subscribe to default exchange topic
routingkey will be notify
Upvotes: 1