File tree Expand file tree Collapse file tree
packages/microservices/client Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ export class ClientRMQ extends ClientProxy {
7474 }
7575 this . client = this . createClient ( ) ;
7676 this . handleError ( this . client ) ;
77+ this . handleDisconnectError ( this . client ) ;
7778
7879 const connect$ = this . connect$ ( this . client ) ;
7980 this . connection = this . mergeDisconnectEvent ( this . client , connect$ )
@@ -83,11 +84,6 @@ export class ClientRMQ extends ClientProxy {
8384 )
8485 . toPromise ( ) ;
8586
86- this . client . on ( DISCONNECT_EVENT , ( err ) => {
87- this . close ( ) ;
88- this . client = null ;
89- } ) ;
90-
9187 return this . connection ;
9288 }
9389
@@ -140,6 +136,14 @@ export class ClientRMQ extends ClientProxy {
140136 client . addListener ( ERROR_EVENT , ( err : any ) => this . logger . error ( err ) ) ;
141137 }
142138
139+ public handleDisconnectError ( client : any ) : void {
140+ client . addListener ( DISCONNECT_EVENT , ( err : any ) => {
141+ this . close ( ) ;
142+ this . client = null ;
143+ return this . logger . error ( err ) ;
144+ } ) ;
145+ }
146+
143147 public handleMessage (
144148 packet : unknown ,
145149 callback : ( packet : WritePacket ) => any ,
You can’t perform that action at this time.
0 commit comments