Reputation: 1547
Update: I posted this code here, after I added all (to 99%) possibilities one by one, and it still gave me a 120sec timeout...buffled.
So, ok, I figured it takes exactly 120sec (ok, 122sec) on my Windows 7 machine, until the FIN
handshake is started. I want to do it immediately. HTTP RFC793 says
FIN: No more data from sender
Looks to me I do not send any data anymore. I tried all this bloated code, still a Hello World
server...
var http = require('http')
var server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'})
res.write('HELLO WORLD!\n')
res.end()
res.setTimeout(0)
req.abort() // 1) TypeError: Object #<IncomingMessage> has no method 'abort'
req.on('socket', function (socket) {
socket.setTimeout(0)
socket.on('timeout', function() {
req.abort()
})
})
})
server.timeout = 0
server.setTimeout(0)
server.listen(1337, '192.168.0.101')
RST
like this...) And how to do the whole thing HTTP
conform?
Of course in the end I will be lucky to use nodejs
as in websocket
stuff and all this, but if conversion on my website means a thing of two minutes, and I have a million concurrent users (huh?), sending a FIN
immediately could mean I have two million concurrent users (do the math). ;) Ok, to be on the sure side: Sending a FIN
means the socket is closed?
Ah, eah, ok, since you are on, how do I console.log(res)
or console.log(req)
? It gives me [object Object]
. (Update: I tried console.log(res.toSource())
, gives me a TypeError
?
Edit: Found the answer here.
Upvotes: 1
Views: 932
Reputation: 17160
If you want to close the connection, send a connection: close
header. If you do this, then it will not leave the connection open for reuse.
Upvotes: 2