Node.js:响应的pipe道stream通过HTTPS冻结

我尝试使用Connect来提供静态内容,但是对于大文件(大于40KB),发送了第一个40,960字节的块(有时为32,940字节),然后传输hibernate2分钟,然后传输完成。 当我将stream传递给响应时,我发现它发生了(这是Connect如何发送响应)。

这里是一个代码,在Windows和Linux上的节点0.6.2上再现了一个48,980字节的文件:

var fs = require( "fs" ), https = require("https"); var privateKey = fs.readFileSync( 'privatekey.pem' ).toString(); var certificate = fs.readFileSync( 'certificate.pem' ).toString(); var options = {key: privateKey, cert: certificate}; var server = https.createServer( options, function( req, res ) { var path = __dirname + "/public" + req.url; fs.stat(path, function(err, stat){ if( err ) { res.writeHead(404, {'Content-Type': 'text/html'}); res.end(""+err); } else { res.writeHead(200, { 'Content-Type': 'text/html', 'Content-Length': stat.size}); var stream = fs.createReadStream(path); stream.pipe(res); } } ); } ).listen(8364); 

fs.readFile ,我不能重现:

 var fs = require( "fs" ), https = require("https"); var privateKey = fs.readFileSync( 'privatekey.pem' ).toString(); var certificate = fs.readFileSync( 'certificate.pem' ).toString(); var options = {key: privateKey, cert: certificate}; var server = https.createServer( options, function( req, res ) { fs.readFile(__dirname + "/public" + req.url, function(err, data){ if( err ) { res.writeHead(404, {'Content-Type': 'text/html'}); res.end(""+err); } else { res.writeHead(200, { 'Content-Type': 'text/html', 'Content-Length': data.length}); res.end(data); } } ); } ).listen(8364); 

我做错什么了吗?

这是这个问题: https : //github.com/joyent/node/issues/2198

固定在节点0.6.4!

我有非常类似的问题,与pipe道(可能是相关的) 在nodejs上的Valumsfile upload器 – 多个file upload

也有2分钟的睡眠。 没有find解决scheme与pipe道做了一些解决方法。