Configuring socket timeout on amqplib connect in nodejs
If the RabbitMQ instance if found error then it takes about 120 seconds to timeout before trying to the error
Here is my code used for connecting:
// Function to connect with the amqp server.
async function connectAmqp() {
try {
// Create amqp connection and is there any error then exit with error.
cluster = await amqp.connect(`amqp://${config.rabbitmq.host}:${config.rabbitmq.port}?heartbeat=0&connection_timeout=120000`);
return cluster;
} catch (error) {
throw error;
}
}
Read more here: Source link