question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting "Invalid header" error when invoking `message.ack()`

See original GitHub issue

I get this error when I invoke message.ack():

Broker reported error: Invalid header [some-file].js:78 Additional details: “ACK” must include a valid “id” header

Initially I was invoking .ack() with no arguments as shown in the docs, i.e. just simply message.ack().

However after first noticing the error and seeing that those docs state that all 3 arguments are not optional, I changed to this:

const messageId = message.headers['message-id'] || undefined;
const subscriptionId = message.headers.subscription || undefined;
message.ack(messageId, subscriptionId, {});

I still got the error, so I switched to this:

const messageId = message.headers['message-id'] || undefined;
const subscriptionId = message.headers.subscription || undefined;
message.ack(messageId, subscriptionId, message.headers);

And I’m still getting the error. How can I fix this error? Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kum-deepakcommented, Dec 14, 2020

I could notice one critical difference, your log output does not show an ack header in the message (below is a sample from my system with RabbitMQ 3.8.0):

{
    content-length:19
    ack:T_sub-0@@session-TjU8h1vFUcIq6w8APXdl2Q@@1
    redelivered:false
    message-id:T_sub-0@@session-TjU8h1vFUcIq6w8APXdl2Q@@1
    destination:/queue/test01
    subscription:sub-0
    content-length:19
}

Are you setting correct headers when subscribing? Please see https://stomp-js.github.io/guide/stompjs/using-stompjs-v5.html#acknowledgment. You need to set { ack: 'client' } to use ack/nack.

0reactions
CodeWithOzcommented, Dec 14, 2020

Thanks! I needed to add { ack: 'client' } when subscribing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I am getting an "Invalid Host header" message when ...
The problem occurs because webpack-dev-server 2.4.4 adds a host check. You can disable it by adding this to your webpack config:
Read more >
FIX: Invalid message error if the header field is longer than ...
Fixes an issue that triggers an invalid message error if a message in BizTalk Server has a header field that's more than 1000...
Read more >
Why I am getting " Attempt to use invalid header in request"
I am trying to upload a file by using REST API in salesforce but getting the above error. public static PageReference upload(String at,Blob ......
Read more >
Error 10012 - Invalid value for header
This error message indicates that the value passed in the header is invalid. From the LongMessage tag, it indicates that US is not...
Read more >
HTTP response status codes - MDN Web Docs - Mozilla
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found