CarlosMagalhaes
CarlosMagalhaes

Reputation: 91

RabbitMQ in NestJS, error on both Producer and Consumer

I have the following app https://github.com/rengthp/nestjs-rabbitmq-microservice

But I get on Producer :

[Nest] 6156 - 04/03/2021, 13:28:53 [ClientProxy] Disconnected from RMQ. Trying to reconnect. +25469ms [Nest] 6156 - 04/03/2021, 13:28:53 [ClientProxy] Object:

{
  "err": {
    "code": 406,
    "classId": 50,
    "methodId": 10
  }
}
 +3ms

and on Consumer:

111ms
[Nest] 1180   - 04/03/2021, 13:22:31   [Server] Disconnected from RMQ. Trying to reconnect. +1058ms
[Nest] 1180   - 04/03/2021, 13:22:37   [Server] Disconnected from RMQ. Trying to reconnect. +6006ms
[Nest] 1180   - 04/03/2021, 13:22:43   [Server] Disconnected from RMQ. Trying to reconnect. +6017ms
[Nest] 1180   - 04/03/2021, 13:22:49   [Server] Disconnected from RMQ. Trying to reconnect. +6026ms

What could be wrong? the server is working...

Upvotes: 4

Views: 7182

Answers (3)

Edgar Olivar
Edgar Olivar

Reputation: 1975

try to left time to api gateway to connect rabbit,

in your controller, use onApplicationBootstrap function

async onApplicationBootstrap() { await this._clientProxyUser.connect();}

you can read more here lifecycle events nestjs

Upvotes: 2

DamarOwen
DamarOwen

Reputation: 177

This error came up because you re-declare an existing queue with different parameters. The solution is simple. The option queue for both producers and consumers must be the same and all option parameters must be the same.

Upvotes: 2

CarlosMagalhaes
CarlosMagalhaes

Reputation: 91

For me changing the type of the RabbitMQ QUEUE I was using from transient to durable fixed it

Upvotes: 0

Related Questions