Skip to content

Commit

Permalink
feat: immediately reconnect on amqplib connect timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
luddd3 committed Aug 24, 2021
1 parent 69f1da3 commit ad06108
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/AmqpConnectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,12 @@ export default class AmqpConnectionManager extends EventEmitter {
this._currentConnection = null;
this._connectPromise = null;

// TODO: Probably want to try right away here, especially if there are multiple brokers to try...
const handle = wait(this.reconnectTimeInSeconds * 1000);
let handle;
if (err.name === 'OperationalError' && err.message === 'connect ETIMEDOUT') {
handle = wait(0);
} else {
handle = wait(this.reconnectTimeInSeconds * 1000);
}
this._cancelRetriesHandler = handle.cancel;

return handle.promise().then(() => this._connect());
Expand Down

0 comments on commit ad06108

Please sign in to comment.