@@ -118,17 +118,32 @@ export class TxSendModuleService {
118
118
}
119
119
120
120
async connect ( ) {
121
- Logger . log ( 'Connecting Rabbit' ) ;
122
- const connection = await amqp . connect (
123
- this . configService . get ( 'RABBIT_MQ_URI' ) ,
124
- ) ;
125
- this . channel = await connection . createChannel ( ) ;
126
- const { address : granterAddress } =
127
- await this . hidWalletService . generateWallet (
128
- this . configService . get ( 'MNEMONIC' ) ,
121
+ try {
122
+ Logger . log ( 'Connecting Rabbit' ) ;
123
+ const connection = await amqp . connect (
124
+ this . configService . get ( 'RABBIT_MQ_URI' ) ,
129
125
) ;
130
- this . granterAddress = granterAddress ;
131
- Logger . log ( 'Connected Rabbit' ) ;
126
+ connection . on ( 'error' , ( err ) => {
127
+ console . error ( 'Connection error:' , err ) ;
128
+ } ) ;
129
+
130
+ connection . on ( 'close' , ( ) => {
131
+ Logger . error ( 'Connection closed, reconnecting...' , 'RabbitMQ' ) ;
132
+ } ) ;
133
+ this . channel = await connection . createChannel ( ) ;
134
+ this . channel . on ( 'error' , ( err ) => {
135
+ Logger . error ( err , 'RabbitMQ' ) ;
136
+ } ) ;
137
+
138
+ const { address : granterAddress } =
139
+ await this . hidWalletService . generateWallet (
140
+ this . configService . get ( 'MNEMONIC' ) ,
141
+ ) ;
142
+ this . granterAddress = granterAddress ;
143
+ Logger . log ( 'Connected Rabbit' ) ;
144
+ } catch ( error ) {
145
+ Logger . error ( error , 'RabbitMQ' ) ;
146
+ }
132
147
}
133
148
134
149
async prepareRegisterCredentialStatus (
0 commit comments