在nodejs中的AMQPLIB连接上配置套接字超时
如果RabbitMQ实例如果找到错误,则大约需要120秒才能超时,然后尝试错误,
这是我用于连接的代码:
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;
}
}
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;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您正在使用
amqplib
。第二个参数为
timeout
值。它在此
Assuming you are using
amqplib
.The second argument takes the
timeout
value.It was added in this PR