Skip to main content

AMQPLib and RabbitMQ

Channel closed by server: 406 (PRECONDITION-FAILED) with message "PRECONDITION_FAILED

As explained by this article this implies that your channel has consumed a message without ACKing or NACKing it and it has timed out. Make sure to ACK or NACK all messages when you receive them - typically after processing just in case something goes wrong there.

this.channel?.consume(q?.queue, (msg: amqplib.ConsumeMessage | null) => {

            if(!msg){
                throw new Error(`Received a null message - weirdness.`)
            }

            try{

                const result = callback(msg)

                this.channel?.ack(msg)

                return result

            }catch(err) {
                console.log(err)
                this.channel?.nack(msg)
            }
})