Closed ambrop72 closed 3 years ago
https://github.com/uNetworking/uWebSockets.js/blob/master/examples/Backpressure.js
getBufferedAmount returns user space backpressure. You also have kernel space backpressure which is not counted. So it fills up seemingly non-linearly.
So why does WebSocket::send() fail when the kernel backpressure fills up, shouldn't it put data in the user space buffer whose size is reported by getBufferedAmount()?
I don't know what you mean by "fail". You either succeed to write the data to kernel space, or it buffers up in user space. You need maxBackpressure set to something higher than 0. Did you check the example I linked? It demonstrates exactly this.
What I am seeing is that send() returns false. I do not know what this means. Was the message placed in the user-space buffer or discarded?
Hi,
According to the documentation WebSocket::getBufferedAmount() returns the amount of buffered data to be sent. However, what I am seeing in my application is that it always returns 0. In my test case I am sending data faster than the client can receive/process it. Before each WebSocket::send(), I check getBufferedAmount() with the intent of not sending at that time if too much data is buffered. However getBufferedAmount() is always zero and at some point send() just returns false, despite getBufferedAmount() having returned 0 just prior
The documentation even suggests to check getBufferedAmount to detect backpressure, clearly this is not working for me.