'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:
async function connectAmqp() {
try {
// Create amqp connection and is there any error then exit with error.
cluster = await amqp.connect(`amqp://127.0.0.1:5672`,{
timeout:2000
});
return cluster;
} catch (error) {
throw error;
}
}
Solution 1:[1]
Assuming you are using amqplib.
The second argument takes the timeout value.
It was added in this PR
const amqp = require('amqplib');
const connection = await amqp.connect('amqp://localhost', {
timeout: 2000,
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Satya S |
