-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Closed
Labels
for: stackoverflowA question that's better suited to stackoverflow.comA question that's better suited to stackoverflow.comstatus: invalidAn issue that we don't feel is validAn issue that we don't feel is valid
Description
Exact problem was already posted to stackoverflow by another user. But nobody answer to that thead and i am posting it here. I have also sample Github project that shows user destinations are not working.
http://stackoverflow.com/questions/28065489/diagnosing-issues-with-spring-websocket-user-destinations
https://github.com/srikrishnacj/Spring-Boot-Websocket-User-Destinations-Issue
My application.properties as follows
security.user.name=cj
security.user.password=cj
My JavaScript as follows
var socket = new SockJS('/ws');
sc = Stomp.over(socket);
sc.connect({}, function(frame) {
console.log('Connected: ' + frame);
sc.subscribe("/user/feed",onr);
setTimeout(function(){sc.subscribe("/app/feed",onr);},1000);
});
function onr(json){
console.log(json);
}
My WebSocket Configuration as follows
registry.enableSimpleBroker("/topic");
registry.setApplicationDestinationPrefixes("/app");
My Controller as follows
@SubscribeMapping("/feed")
public String onAppSubscription(Principal principal) {
System.out.println("Subscription request to: /app/feed >>> " + principal.getName());
template.convertAndSendToUser(principal.getName(), "/feed", "Test Message"); // wont work
return "Subscription Complete"; // this will work
}
What i am doing above is
- user subscribes to user destination
- user subscribes to application destination
-> in controller i am sending a test message to user destintaion via websocket template. but it does not work
negarnegma
Metadata
Metadata
Assignees
Labels
for: stackoverflowA question that's better suited to stackoverflow.comA question that's better suited to stackoverflow.comstatus: invalidAn issue that we don't feel is validAn issue that we don't feel is valid