@onlineapps/mq-client-core 1.0.19 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -59,7 +59,15 @@ class RabbitMQClient extends EventEmitter {
|
|
|
59
59
|
*/
|
|
60
60
|
async connect() {
|
|
61
61
|
try {
|
|
62
|
-
|
|
62
|
+
console.log(`[RabbitMQClient] Attempting to connect to: ${this._config.host}`);
|
|
63
|
+
// Add connection timeout to prevent hanging
|
|
64
|
+
const connectPromise = amqp.connect(this._config.host);
|
|
65
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
66
|
+
setTimeout(() => reject(new Error('Connection timeout after 10 seconds')), 10000);
|
|
67
|
+
});
|
|
68
|
+
console.log(`[RabbitMQClient] Starting connection race...`);
|
|
69
|
+
this._connection = await Promise.race([connectPromise, timeoutPromise]);
|
|
70
|
+
console.log(`[RabbitMQClient] Connection established`);
|
|
63
71
|
this._connection.on('error', (err) => this.emit('error', err));
|
|
64
72
|
this._connection.on('close', () => {
|
|
65
73
|
// Emit a connection close error to notify listeners
|