0

I am using node-amqp to connect to RabbitMQ. The setup is as follows:

  • two RabbitMQ servers ("rabbits" henceforth), one called "incoming" the other "notifier".
  • Data is published to the "incoming" rabbit, and my app buffers (the "buffer" app) a certain number of messages before writing them to a database.
  • The buffer then tries to publish these messages to the "notifier" rabbit, which is designed to notify other parts of the system (like the UI).

Pulling messages off "incoming" is fine, and writing to the database etc. all works, but when it comes to publishing to "notifier" I get the following error after attempting to publish the first couple of messages:

Unhandled connection error: UNEXPECTED_FRAME - expected content header for class 60, got non content header frame instead

The connection looks like this:

self.exchangeOpen = new Promise(function(resolve) {
    var exchangeOptions = {
        type:       'fanout',
        autoDelete: false,
        confirm:    true
    };
    conn.exchange(opts.exchange, exchangeOptions, function(exchange) {
        debug('exchange %s opened', opts.exchange);
        self.exchange = exchange;
        resolve(exchange);
    });
});

(I do see the exchange opened message, so it does actually successfully open it.)

I am then publishing to this exchange as follows:

publish: function(data) {
    var self = this;

    debug('publishing data');

    return new Promise(function(resolve) {
        self.exchange.publish('', data, { contentType: 'application/json' }, function() {
            debug('data published!');
            resolve(data);
        });
    });
}

And this is called in a loop once the data has been written to the database.

This error only pops up once, but when I look in the RabbitMQ management interface, no messages are getting published to the queue at all. I've tried changing the queue type from fanout to topic but to no avail. Additionally, the confirm: true flag appears to do nothing as the confirmation callback is never called. This means I can't wait for message confirmation before publishing a new message.

I can't work out what the problem is, as the error message is a bit cryptic. It could be to do with the attempt to publish many things (nearly) simultaneously, but without the confirmation callback I can't stop this happening...

GTF
  • 8,031
  • 5
  • 36
  • 59
  • Since you are using Promises already, any reason for not using this library? https://github.com/squaremo/amqp.node/ that's the one the RabbitMQ team recommends using – old_sound Apr 01 '15 at 10:45
  • No particular reason other than that node-amqp seems reasonably well used (anecdotally). I'll look at amqplib, but have fixed the problem by using ascoltatori (not sure why it's fixed, only that it's fixed). – GTF Apr 01 '15 at 19:19
  • AFAIK node-amqp is not maintained anymore – old_sound Apr 02 '15 at 13:39

0 Answers0