Skip to content

Disabling Keep-Alive #1281

Closed
Closed
@koxu1996

Description

@koxu1996
  • Node.js Version: v10.1.0
  • OS: Linux archPC 4.16.9-1-ARCH #1 SMP PREEMPT Thu May 17 02:10:09 UTC 2018 x86_64 GNU/Linux
  • Scope (install, code, runtime, meta, other?): code
  • Module (and version) (if relevant): http

I created issue nodejs/node#20807, but I was adivsed to ask here. I want to completely disable Keep-Alive, so I use setKeepAlive(false), but it does not have any effect. Server code:

var http = require('http')

var server = http.createServer(function(req, res) {
    res.end('Hello Node.js Server!')
})

server.on('connection', function(socket) {
    socket.setKeepAlive(false)
})

server.listen(8080)

I tested it with browser and telnet:

$ telnet 127.0.0.1 8080
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
GET / HTTP/1.1

HTTP/1.1 200 OK
Date: Thu, 17 May 2018 21:05:25 GMT
Connection: keep-alive
Content-Length: 21

Hello Node.js Server!

As you can see, there is Connection: keep-alive header. I also tried Node.js v8.11.2 but effect was the same. Am I doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions