stomp-js / stompjs

Javascript and Typescript Stomp client for Web browsers and node.js apps
Apache License 2.0
776 stars 81 forks source link

Stomp isn't publishing the payload #610

Open dipliee opened 1 year ago

dipliee commented 1 year ago

Using stompJs 7.0.0 After establishing a connection with my server, the client tries to publish a payload and the server doesn't receive anything. on the client side i get a log >>> SEND destination:undefined. Also subscribed but nothing receiving on the client side after publishing. >>> SUBSCRIBE id:sub-0 destination:/topic/broadcast This is my setup on the client side :

$("#subscribe").click(function () {
    client.subscribe('/topic/broadcast', function (message) {
        const msg = JSON.parse(message.body);
        alert(msg);
    });
});

$("#send").click(function () {
    var chatMessage = {
        from: 'diogo',
        content: 'fdd',
        type: 'TEXT'
    };
    client.publish({
      destination: '/app/chat.sendMessage',
      body: JSON.stringify(chatMessage),
      headers: {'content-type': 'application/json'}
    });
});

On the server side im using spring boot with rabbitmq Controller on the server side :

@MessageMapping("/chat.sendMessage")
    @SendTo("/topic/broadcast")
    fun sendMessage(@Payload message: ChatMessage): ChatMessage{
        println(message)
        return message
  }

Im on this for a about a 1 week plus a few days, read the docs but can't reach a conclusion on this, i have the correct endpoints, the rabbitmq is running and with the STOMPJs plugin and there is no update on message or queued charts in the rabbitmq, is this a configuration missing ? Thanks in advance.