abreits / amqp-ts

AmqpSimple, a RabbitMQ tested Amqp library written in and for Typescript
MIT License
131 stars 42 forks source link

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

Open marcopogo81 opened 7 years ago

marcopogo81 commented 7 years ago

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)=>{
...
}
fan-tom commented 4 years ago

Affects me too, very annoying

justinrush commented 4 years ago

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?

michaelgriffithus commented 2 years ago

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}`));
  }