IronMQ empty message body from push queue when read from Node.JS / Express.JS


I'm playing with node + express + IronMQ and I'm encountering a little problem.

In my express.js POST callback I'm getting {} as request body but I'm sure that the message content is being pushed from my IronMQ message queue.

Any hint ?

Problem courtesy of: thomas.g


IronMQ have now updated their push queues to send custom headers. If you set the headers to 'Content-Type': 'application/json' in the list of subscribers when creating the queue, then the body gets parsed correctly. eg

# update groups queue
payload =
  subscribers: [
      url: "#{process.env.ROOT_URL}/groups/update"
        'Content-Type': 'application/json' # this fixes request parsing issue
  push_type: 'multicast'
  retries: 3
  retries_delay: 10
  error_queue: 'groups_errors'

url = "{process.env.IRON_MQ_PROJECT_ID}/queues/groups"

headers =
  'Authorization': "OAuth #{process.env.IRON_MQ_TOKEN}"
  'Content-Type': 'application/json'

result = url, {headers: headers, content: JSON.stringify(payload)}

Here's the relevant change on github

Solution courtesy of: ukoki


Ok I've found both the reason of my problem and its solution. So to answer my own question:


1) I'm receiving POST messages from an IronMQ push queue (, their content type is text/plain.

2) I'm using connect.js middleware (express.connect) and it parses only application/json,application/x-www-form-urlencoded, and multipart/form-data.

So the body gets parsed and as its content type is not supported the result is {}


In order to get the body of my text/plain request I had to parse it by myself as in

Discussion courtesy of: thomas.g

This recipe can be found in it's original form on Stack Over Flow.