@onlineapps/mq-client-core 1.0.20 → 1.0.22
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
package/src/BaseClient.js
CHANGED
|
@@ -57,17 +57,22 @@ class BaseClient {
|
|
|
57
57
|
async connect(options = {}) {
|
|
58
58
|
if (this._connected) return;
|
|
59
59
|
|
|
60
|
+
console.log(`[BaseClient] Starting connect() with config:`, JSON.stringify({ type: this._config.type, host: this._config.host }));
|
|
60
61
|
// Merge overrides into existing config
|
|
61
62
|
this._config = merge({}, this._config, options);
|
|
62
63
|
|
|
63
64
|
try {
|
|
65
|
+
console.log(`[BaseClient] Creating transport...`);
|
|
64
66
|
// Instantiate appropriate transport: RabbitMQClient
|
|
65
67
|
this._transport = transportFactory.create(this._config);
|
|
68
|
+
console.log(`[BaseClient] Transport created:`, this._transport.constructor.name);
|
|
66
69
|
|
|
67
70
|
// Register internal error propagation
|
|
68
71
|
this._transport.on('error', (err) => this._handleError(err));
|
|
69
72
|
|
|
73
|
+
console.log(`[BaseClient] Calling transport.connect()...`);
|
|
70
74
|
await this._transport.connect(this._config);
|
|
75
|
+
console.log(`[BaseClient] Transport connected successfully`);
|
|
71
76
|
this._connected = true;
|
|
72
77
|
} catch (err) {
|
|
73
78
|
throw new ConnectionError('Failed to connect to broker', err);
|
|
@@ -59,12 +59,15 @@ class RabbitMQClient extends EventEmitter {
|
|
|
59
59
|
*/
|
|
60
60
|
async connect() {
|
|
61
61
|
try {
|
|
62
|
+
console.log(`[RabbitMQClient] Attempting to connect to: ${this._config.host}`);
|
|
62
63
|
// Add connection timeout to prevent hanging
|
|
63
64
|
const connectPromise = amqp.connect(this._config.host);
|
|
64
65
|
const timeoutPromise = new Promise((_, reject) => {
|
|
65
66
|
setTimeout(() => reject(new Error('Connection timeout after 10 seconds')), 10000);
|
|
66
67
|
});
|
|
68
|
+
console.log(`[RabbitMQClient] Starting connection race...`);
|
|
67
69
|
this._connection = await Promise.race([connectPromise, timeoutPromise]);
|
|
70
|
+
console.log(`[RabbitMQClient] Connection established`);
|
|
68
71
|
this._connection.on('error', (err) => this.emit('error', err));
|
|
69
72
|
this._connection.on('close', () => {
|
|
70
73
|
// Emit a connection close error to notify listeners
|