metalbear-co / mirrord

Connect your local process and your cloud environment, and run local code in cloud conditions.
https://mirrord.dev
MIT License
3.58k stars 98 forks source link

rabbitmq + node + macOS doesn't connect #2558

Closed aviramha closed 2 days ago

aviramha commented 2 days ago

One of our users reported that when using rabbitmq (3.9.5) + Node v20 + macOS it fails to connect. When I tried to reproduce using this script:

const amqp = require('amqp-connection-manager');

// Create a connection manager
const connection = amqp.connect(['amqp://user:11cuJAQBH5sf9fad@rmq-rabbitmq'], {
  heartbeatIntervalInSeconds: 30,
  connectionOptions: {
    noDelay: true,
    timeout: 60,
    keepAlive: true,
  },
});

const QUEUE_NAME = 'amqp-connection-manager-sample2'
const EXCHANGE_NAME = 'amqp-connection-manager-sample2-ex';

// Handle an incomming message.
const onMessage = data => {
    var message = JSON.parse(data.content.toString());
    console.log("subscriber: got message", message);
    channelWrapper.ack(data);
}

// Create a connetion manager
connection.on('connect', () => console.log('Connected!'));
connection.on('disconnect', err => console.log('Disconnected.', err.stack));

// Set up a channel listening for messages in the queue.
var channelWrapper = connection.createChannel({
    setup: channel => {
        // `channel` here is a regular amqplib `ConfirmChannel`.
        return Promise.all([
            channel.assertQueue(QUEUE_NAME, { exclusive: true, autoDelete: true }),
            channel.assertExchange(EXCHANGE_NAME, 'topic'),
            channel.prefetch(1),
            channel.bindQueue(QUEUE_NAME, EXCHANGE_NAME, '#'),
            channel.consume(QUEUE_NAME, onMessage)
        ])
}});

channelWrapper.waitForConnect()
.then(function() {
    console.log("Listening for messages");
});

I saw that it's resolving DNS and not connecting. but when I run without mirrord, I can see it tries to connect - perhaps it's connecting in a way ignored by mirrord? :O

aviramha commented 2 days ago

Issue is probably timeout. User set it to 60 which is 60ms and not seconds.