Reputation: 23
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)
Upvotes: 1
Views: 657
Reputation: 6255
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"
Upvotes: 1