Closed vnStrawHat closed 3 years ago
This is not how it works. You need to read the documentation for these options and events, and look at examples. There are plenty of comments regarding this. Drain event fires when backpressure drains, drainage can happen before reaching maxBackpressure.
Hi,
My case use pub/sub and I see in the document:
getBufferedAmount(): Returns the bytes buffered in backpressure
Publish(): Also keep in mind that backpressure will be automatically managed with pub/sub, meaning some outgoing messages may be dropped if backpressure is greater than specified maxBackpressure.
My concerns is:
Drain event fires after it drains, not before: 100,000 - drain amount = 65,000
Hi,
I have problem with option maxBackpressure that seen not work. For my understand, if ws.getBufferedAmount() > maxBackpressure => websocket have drained. I was set maxBackpressure = 100000 and print ws.getBufferedAmount() every 1s. The result of ws.getBufferedAmount() seen to be can not great than 66k. The maximum value is 65593, it lower than maxBackpressure but drain() still triggered
Bellow is sample code:
app = uWS.App({ maxPayloadLength: 16 * 1024, compression: uWS.SHARED_COMPRESSOR, maxBackpressure: 100000 })
open: (ws) => { setInterval(() => { console.log("bufferedAmount: " + ws.getBufferedAmount()) }, 1000) }
drain: (ws) => { console.log("drained: " + ws.getBufferedAmount()) }
P/s: English is not my primary language. Sorry for that.