cloudamqp/amqp-client.js

Be able to specify timeout

everhardt opened this issue · 2 comments

It takes a very long time before a connection attempt times out. Right now there's no way to configure a connect timeout in the AMQPClient constructor or the .connect() function, which would be great to have.

For now, I wrote the following workaround:

    const connectionPromise = amqp.connect();
    amqp.socket?.setTimeout(5000);
    connection = await new Promise((resolve, reject) => {
      amqp.socket?.on('timeout', () => {
        amqp.socket?.destroy();
        reject(new DestinationError('Timeout hit'));
      });
      connectionPromise.then(resolve).catch(reject);
    });

Pretty sure #78 improved on this, are you able to check @everhardt? Using the heartbeat parameter you can control the timeout

Thanks @dentarg. I think so too. I'll monitor the situation and will reopen if it does not work properly