Skip to content

user destinations are not working #5360

@srikrishnacj

Description

@srikrishnacj

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

  1. user subscribes to user destination
  2. user subscribes to application destination
    -> in controller i am sending a test message to user destintaion via websocket template. but it does not work

Metadata

Metadata

Assignees

Labels

for: stackoverflowA question that's better suited to stackoverflow.comstatus: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions