rabbitmq 在nodejs中配置amqplib连接的套接字超时

cig3rfwq  于 2022-11-08  发布在  RabbitMQ
关注(0)|答案(1)|浏览(259)

如果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;
            }
        }
nvbavucw

nvbavucw1#

假设您使用的是amqplib
第二个参数采用timeout值。
它已添加到此PR

const amqp = require('amqplib');

const connection = await amqp.connect('amqp://localhost', {
  timeout: 2000,
});

相关问题