[英]How to send the 'FIN' with node.js?
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. 更新:我在此代码中逐一添加了所有(到99%)的可能性之后,在这里发布了此代码,但它仍然给了我120秒的超时时间……...住了。
So, ok, I figured it takes exactly 120sec (ok, 122sec) on my Windows 7 machine, until the FIN
handshake is started. 因此,好吧,我发现在Windows 7计算机上,要开始
FIN
握手之前,它只需要120秒(好,就是122秒)。 I want to do it immediately. 我要立即做。 HTTP RFC793 says
HTTP RFC793说
FIN: No more data from sender
FIN:没有来自发件人的更多数据
Looks to me I do not send any data anymore. 在我看来,我不再发送任何数据。 I tried all this bloated code, still a
Hello World
server... 我尝试了所有这些肿的代码,仍然是
Hello World
服务器...
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...) RST
...) And how to do the whole thing HTTP
conform? 以及如何使整个
HTTP
符合要求?
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). 当然,最后我会很幸运地在
websocket
内容中使用nodejs
,但如果在我的网站上进行转换意味着两分钟的时间,并且我有100万并发用户(呵呵),立即发送FIN
可能表示我有200万并发用户(进行数学计算)。 ;) Ok, to be on the sure side: Sending a FIN
means the socket is closed? ;)好的,可以肯定的是:发送
FIN
表示套接字已关闭?
Ah, eah, ok, since you are on, how do I console.log(res)
or console.log(req)
? 嗯,嗯,好的,既然您打开了,我该如何
console.log(res)
或console.log(req)
? It gives me [object Object]
. 它给了我
[object Object]
。 (Update: I tried console.log(res.toSource())
, gives me a TypeError
? (更新:我尝试
console.log(res.toSource())
,给我TypeError
吗?
Edit: Found the answer here . 编辑:在这里找到答案。
If you want to close the connection, send a connection: close
header. 如果要关闭连接,请发送一个
connection: close
标头。 If you do this, then it will not leave the connection open for reuse. 如果执行此操作,则它将不会保持连接打开以供重用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.