diff --git a/package.json b/package.json index 1778a7d..3555ba6 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "@nestjs/config": "^2.2.0", "@nestjs/core": "^9.0.0", "@nestjs/jwt": "^10.0.1", + "node-cache": "^5.1.2", "@nestjs/mongoose": "^9.2.1", "@nestjs/passport": "^9.0.0", "@nestjs/platform-express": "^9.0.0", diff --git a/src/tx-send-module/tx-send-module.service.ts b/src/tx-send-module/tx-send-module.service.ts index dabed01..124900d 100644 --- a/src/tx-send-module/tx-send-module.service.ts +++ b/src/tx-send-module/tx-send-module.service.ts @@ -118,17 +118,32 @@ export class TxSendModuleService { } async connect() { - Logger.log('Connecting Rabbit'); - const connection = await amqp.connect( - this.configService.get('RABBIT_MQ_URI'), - ); - this.channel = await connection.createChannel(); - const { address: granterAddress } = - await this.hidWalletService.generateWallet( - this.configService.get('MNEMONIC'), + try { + Logger.log('Connecting Rabbit'); + const connection = await amqp.connect( + this.configService.get('RABBIT_MQ_URI'), ); - this.granterAddress = granterAddress; - Logger.log('Connected Rabbit'); + connection.on('error', (err) => { + console.error('Connection error:', err); + }); + + connection.on('close', () => { + Logger.error('Connection closed, reconnecting...', 'RabbitMQ'); + }); + this.channel = await connection.createChannel(); + this.channel.on('error', (err) => { + Logger.error(err, 'RabbitMQ'); + }); + + const { address: granterAddress } = + await this.hidWalletService.generateWallet( + this.configService.get('MNEMONIC'), + ); + this.granterAddress = granterAddress; + Logger.log('Connected Rabbit'); + } catch (error) { + Logger.error(error, 'RabbitMQ'); + } } async prepareRegisterCredentialStatus(