1

i want to send and save some data in the rabbit; after a while that i run my code and after some sending data into my rabbit i get some error like this: Error: No channels left to allocate

i use from this code several times because i have several data to send into rabbitMQ

let open = require('amqplib').connect('amqp://localhost:5672')


    open.then(function (conn) {
      return conn.createChannel()
    }).then(function (ch) {
      return ch.assertQueue(q).then(function (ok) {
        ch.sendToQueue(q, Buffer.from(JSON.stringify(data)))
        return ch.close()
      })
    }).catch(console.warn)
Mojax Razmi
  • 23
  • 1
  • 6

1 Answers1

1

Looks like you are creating new channels when you are publishing messages.

I solved the issue in this question

Rabbit MQ amqplib error "No channels left to allocate"

vanduc1102
  • 5,769
  • 1
  • 46
  • 43