You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Platform: Darwin Mariuss-MBP-2.lan 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64
Subsystem: http
In case timeout is reached for server.headersTimeout, node keeps the socket open until it receives data or server.timeout is reached.
I believe this issue causes dropped connections / 502 errors on AWS ALB (load balancer), because it tries to send data and socket closes immediately after data is received.
I have set server.headersTimeout = 10 * 1000 and ran tcpdump to confirm.
As you can see in the dump, 24 seconds has passed, data was received, acknowledged and socket closed after data was received.
I expected socket to be closed after 10 seconds has passed without data.
The text was updated successfully, but these errors were encountered:
I tried to reproduce what is described in this issue (see attached snippets at the end), but I wasn't able to:
When connectionsCheckingInterval is set to a value lower than the headersTimeout, the timeout triggers as expected and the socket is closed.
When connectionsCheckingInterval is higher, then the timeout is not triggered (I first thought this might be how to get into this case), but still the socket won't get closed when it is written to. Instead, the request will just be handled is if there was no headers timeout.
This is the behavior I observed on both node 11.6.0 (report) and 22.1.0 (current) - 23.4.0 Darwin fwiw.
Repro attempt source
// server.jsconsthttp=require("http");constserver=http.createServer({// connectionsCheckingInterval: 1000, // enable this to trigger headersTimeout},(req,res)=>{res.writeHead(200,{"Content-Type": "text/plain"});res.end("Hello, World!\n");});server.headersTimeout=5*1000;// 5 secondsserver.timeout=30*1000;// 30 secondsserver.listen(3000,()=>{console.log("Server running at http://127.0.0.1:3000/");});
// client.jsconstnet=require('net');constclient=newnet.Socket();client.connect(3000,'127.0.0.1',()=>{console.log('Connected to server');client.write('GET / HTTP/1.1\r\n')// Wait 10 seconds before sending the request headers to simulate delaysetTimeout(()=>{console.log('Sending remaining request headers');constrequest=['Host: 127.0.0.1','Connection: keep-alive','',''].join('\r\n');client.write(request);},10000);});client.on('data',(data)=>{console.log(`Received: ${data}`);client.destroy();// Kill client after server's response});client.on('close',()=>{console.log('Connection closed');});client.on('error',(err)=>{console.error(`Error: ${err.message}`);});
In case timeout is reached for
server.headersTimeout
, node keeps the socket open until it receives data orserver.timeout
is reached.I believe this issue causes dropped connections / 502 errors on AWS ALB (load balancer), because it tries to send data and socket closes immediately after data is received.
I have set
server.headersTimeout = 10 * 1000
and ran tcpdump to confirm.As you can see in the dump, 24 seconds has passed, data was received, acknowledged and socket closed after data was received.
I expected socket to be closed after 10 seconds has passed without data.
The text was updated successfully, but these errors were encountered: