-
Notifications
You must be signed in to change notification settings - Fork 23
Description
hi,
i have working lavinmq setup with nginx stream proxy for ssl termination , the system is working fine for long time,
i just found a strange issues, the issue is when i publish > 10 jobs in a batch with nodejs, only 2 jobs get added and it throws connection is closed, if i add jobs from local server without nginx in between without ssl everything works. but if i use same code using bun and nginx in between everything works .
main point of issue
- nodejs > nginx SSL > lavinmq in docker ( only two jobs are added )
- bun > nginx SSL > lavinmq in docker ( no issue , all jobs are added )
- nodejs > lavinmq in docker ( no issue , all jobs are added )
- bun > lavinmq in docker ( no issue , all jobs are added )
packages i am using
@cloudamqp/amqp-client 3.2.1
nodejs 22.11.0
bun 1.2.3
lavinmq 2.3.0
here is my code for adding jobs , change jobsToMakePerLoop to see issue , less than 10 works ok with node
import { getConnection } from "./services/connectQServer.mjs"
import { setInterval as setIntervalPromises } from "node:timers/promises"
const conn = await getConnection()
const ch = await conn.channel()
await ch.confirmSelect()
// with bun i can add any number of jobs 1k 10k it works
const jobsToMakePerLoop = 10
const q = await ch.queue(
"test-for-behind-nginx",
{ durable: true },
{ "x-delivery-limit": 3, "x-delivery-count": true, "x-max-priority": 10 },
)
let a = 0
for await (const startTime of setIntervalPromises(10, Date.now())) {
a++
console.log("adding jobs now loop", a)
await addJobs(a)
console.log("loop done", a)
if (a >= 10) {
break
}
}
console.log("closing connection")
await ch?.close()
await conn?.close()
async function addJobs(loop) {
const dummyJobData = { _someId: "id", _key: Date.now() }
let _pos = 0
try {
await Promise.all(
[...Array(jobsToMakePerLoop).keys()].map(() => {
const msgBody = JSON.stringify({
...dummyJobData,
_pos: _pos++,
loop,
})
_pos++
return q.publish(msgBody, {
deliveryMode: 2,
})
}),
)
} catch (error) {
console.log("error in Promise.all", error)
}
}
Error /logs basaed on above code i get with node
adding jobs now loop 1
amqp-client connection closed Socket closed
AMQPError: Channel is closed
at AMQPChannel.rejectClosed (<redacted>/node_modules/.pnpm/@[email protected]/node_modules/@cloudamqp/amqp-client/lib/mjs/amqp-channel.js:774:31)
at AMQPChannel.close (<redacted>/node_modules/.pnpm/@[email protected]/node_modules/@cloudamqp/amqp-client/lib/mjs/amqp-channel.js:53:25)
@cloudamqp/amqp-client 3.2.1
nodejs 22.11.0
bun 1.2.3
lavinmq 2.3.0