Answer the question
In order to leave comments, you need to log in
How to get 408 error in browser?
There is a simple koa server. There is Chrome. The server has this code:
router.post(/\/api\/gw\/query/, async (ctx, next) => {
await sleep(6 * 60000); // 6 минут
});
server.keepAliveTimeout = 2000;
server.headersTimeout = 2000;
// server.setTimeout(5000);
Answer the question
In order to leave comments, you need to log in
Everything turned out to be very simple
. You need to add a timeout (better done for a specific request) in the request
router.post(/\/api\/gw\/query/, async (ctx, next) => {
ctx.request.socket.setTimeout(4000);
await sleep(6 * 60000); // 6 минут
});
const server = app.listen(3000);
server.on('timeout', (socket) => {
console.log('timeout', socket)
socket.write([
'HTTP/1.1 408 Request Timeout',
'Connection: close'
].join('\n') + '\n\n');
socket.end();
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question