今天在查看 node.js 服务日志的时候发现 amqplib 模块报错 No channels left to allocate 。是服务没有复用通道,创建了太多的 channel 导致该问题,通过调试找到报错的问题,在 amqplib/lib/connection.js 中 freshChannel 函数中报错。 具体代码如下: // I use an array to keep track of the channels, rather than an // object. The channel identifiers are numbers, and allocated by the // connection. If I try to allocate low numbers when they are // available (which I do, by looking from the start of the bitset), // this ought to keep the array small, and out of 'sparse array // storage'. I also set entries to null, rather than deleting them, in // the expectation that the next