-
server.jsconst uWS = require('uWebSockets.js');
const uwsapp = uWS.App();
uwsapp.get('/synctest', (res) => res.end(JSON.stringify({ test: 23456 }))); // <-- This works as expected
uwsapp.get('/test', async (res) => {
let isAborted = false;
res.onAborted(() => {
isAborted = true;
});
const { test } = await new Promise((resolve) => {
setTimeout(() => {
resolve({ test: 123 });
}, 1);
});
if (isAborted) {
return;
}
return res.end(JSON.stringify({ test }));
}); // <-- But this doesn't work
uwsapp.listen(8005, (token) => token && console.log('listens at 8005')); and call results❯ autocannon -c100 -p100 -d1 -m GET http://localhost:8005/test
Running 1s test @ http://localhost:8005/test
100 connections with 100 pipelining factor
┌─────────┬───────┬───────┬────────┬────────┬──────────┬──────────┬───────────┐
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
├─────────┼───────┼───────┼────────┼────────┼──────────┼──────────┼───────────┤
│ Latency │ 55 ms │ 72 ms │ 107 ms │ 107 ms │ 83.34 ms │ 19.31 ms │ 107.42 ms │
└─────────┴───────┴───────┴────────┴────────┴──────────┴──────────┴───────────┘
┌───────────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┐
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
├───────────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤
│ Req/Sec │ 6 │ 6 │ 6 │ 6 │ 6 │ 0 │ 6 │
├───────────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤
│ Bytes/Sec │ 426 B │ 426 B │ 426 B │ 426 B │ 426 B │ 0 B │ 426 B │
└───────────┴───────┴───────┴───────┴───────┴───────┴───────┴───────┘
Req/Bytes counts sampled once per second.
6 requests in 1.1s, 426 B read
6 errors (0 timeouts)
~ Or may occur while using |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
This is by design. We had an issue about this before. Pipelining is not supported, it just happens to work if you respond immediately |
Beta Was this translation helpful? Give feedback.
-
Sorry to jump on this old thread. But couldn't find a clearer answer anywhere else. I'll explain: I'm just about ready to update a system with thousands of clients using websockets. I just know I will have many users performing multiple requests simultaneously. Should I not use uWS for this http requests? Thought they were pretty basic. Thanks in advance. |
Beta Was this translation helpful? Give feedback.
-
Almost no tool will use Http1.1 pipelining because it is a really crappy feature and many servers don't even support it (uWS doesn't). No web browser uses it and no proxy uses it. It's not the same as keep-alive (persistent https connections) |
Beta Was this translation helpful? Give feedback.
This is by design. We had an issue about this before. Pipelining is not supported, it just happens to work if you respond immediately