stomp.ack is yielding Error: Unexpected ACK received for message-id
Asked Answered
P

1

6

I have tried possible combinations and searched over the internet but couldn't make this work, error is:

Error: Unexpected ACK received for message-id

It will be really helpful if anyone can point out if there is some conceptual mistake in following code:

var Stomp = require('stomp-client');
var client = new Stomp(host, port, user, pass);
client.connect(function(sessionId) {
    var subId = client.subscribe(/topic/foo, function(body, headers) {
        client.ack(headers['message-id'], subId);
        var message = ['abc', 'def'];
        client.publish(`/topic/bar`, `some_message`);
    }, {ack: 'client'});
    client.on('error', function(er) {
        console.error(er);
    });
});
Painstaking answered 26/1, 2019 at 20:29 Comment(0)
V
3

You are maybe using stomp-1.2 where the acknowledment header is not message-id (stomp-1.0), but ack:

client.ack(headers['ack'], subId);
Viewer answered 10/3, 2020 at 11:52 Comment(1)
This worked for me - but didn't need "subId"Greyhen

© 2022 - 2024 — McMap. All rights reserved.