amqp-ts
amqp-ts copied to clipboard
connection.completeConfiguration() doesn't reject the Promise if the connection string passed is wrong.
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)=>{
...
}
Affects me too, very annoying
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?
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}`));
}