Skip to content

Commit cc5c749

Browse files
committed
fix - [RabbitMQ Microservice] "PRECONDITION_FAILED - reply consumer already set" nestjs#3138
1 parent 32e1bf0 commit cc5c749

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

packages/microservices/client/client-rmq.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ export class ClientRMQ extends ClientProxy {
8282
share(),
8383
)
8484
.toPromise();
85+
86+
this.client.on(DISCONNECT_EVENT, (err)=> {
87+
this.close();
88+
this.client = null;
89+
});
90+
8591
return this.connection;
8692
}
8793

packages/microservices/server/server-rmq.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ export class ServerRMQ extends Server implements CustomTransportStrategy {
6969
public async start(callback?: () => void) {
7070
this.server = this.createClient();
7171
this.server.on(CONNECT_EVENT, (_: any) => {
72+
if (this.channel) {
73+
return;
74+
}
7275
this.channel = this.server.createChannel({
7376
json: false,
7477
setup: (channel: any) => this.setupChannel(channel, callback),

0 commit comments

Comments
 (0)