amqp-ts icon indicating copy to clipboard operation
amqp-ts copied to clipboard

connection.completeConfiguration() doesn't reject the Promise if the connection string passed is wrong.

Open marcopogo81 opened this issue 8 years ago • 3 comments

connection.completeConfiguration() doesn't reject the Promise if the connection string passed is wrong.

//wrong connection string
let connString:string='amqp://donald:duck@ducktales:'+cfg.Port;
let connection = new Amqp.Connection(connString);

let queue = connection.declareQueue("QUEUE_1", { durable: false, prefetch:1, });
queue.activateConsumer(this.onMessage, { noAck: false });

connection.completeConfiguration().then(() => {
       $log.debug('[RabbitConsumer] END - Connection completed');
}).catch((err)=>{
        //never log this
       $log.error('[RabbitConsumer] ERROR: ['+err+']');
});
private onMessage=(message: Amqp.Message)=>{
...
}

marcopogo81 avatar May 18 '17 08:05 marcopogo81

Affects me too, very annoying

fan-tom avatar Apr 23 '20 09:04 fan-tom

Any thoughts for fixing this or working around it? How can I validate a connection or set some sort of timeout on trying to validate the connection with completeConfiguration?

justinrush avatar Sep 02 '20 13:09 justinrush

I am also experiencing this, if the connection string is wrong there is no error thrown.

  const connection = new Amqp.Connection(process.env.AMQP_HOST);
  const queue = connection.declareQueue(myQueue, { durable: true });
  if (queue) {
    logger.debug(`Connected to MQ queue ${myQueue}`);
    const msg = new Amqp.Message(queryStr);
    queue.send(msg);
  } else {
    logger.error(new Error(`Unable to connect to queue ${myQueue}`));
  }

michaelgriffithus avatar Apr 07 '22 18:04 michaelgriffithus