错误:运行nodejs spdy示例时收到rst:1

时间:2013-07-20 11:19:58

标签: node.js spdy

我可以从https://coderwall.com/p/2gfk4w运行示例,但是当我第二次在浏览器中刷新页面时,我在控制台上遇到错误

此示例对spdy使用response.push - 示例代码和错误如下:

代码:

var fs = require('fs');
var spdy = require('spdy');

var backbone = fs.readFileSync('backbone.js');
var underscore = fs.readFileSync('underscore.js');
var applicationjs = fs.readFileSync('application.js');
var indexhtml = fs.readFileSync('index.html');

var options = {
    key: fs.readFileSync('newkeys/server.key'),
    cert: fs.readFileSync('newkeys/server.crt'),
    ca: fs.readFileSync('newkeys/server.csr')
};

var server = spdy.createServer(options, function(request, response) {
    var headers = {
        'content-type': 'application/javascript'
    }

    response.push('/backbone.js', headers, function(err, stream){
        if (err) return;
    stream.end(backbone);
    });

    response.push('/underscore.js', headers, function(err, stream){
        if (err) return;
    stream.end(underscore);
    });

    response.push('/application.js', headers, function(err, stream){
        if (err) return;
    stream.end(applicationjs);
    });

    response.writeHead(200, {'content-type': 'text/html'});
    var message = "No SPDY for you!"
    if (request.isSpdy){
        message = "YAY! SPDY Works!"
    }
    response.end("" +
        "<html>" + 
        "<head>" +
        "<title>First SPDY App!</title>" +
        "<script src='/underscore.js'></script>" +
        "<script src='/backbone.js'></script>" +
        "<script src='/application.js'></script>" +
        "<head>" +
        "<body>" +
        "<h1>" + message + "</h1>" +
        "</body>" +
        "<html>");
});

server.listen(8099, function(){
  console.log("HTTP 1.1 Server started on 8099");
});

错误:

Error: Received rst: 1
    at Parser.<anonymous> (D:\nodejs\node_modules\spdy\lib\spdy\server.js:406:26)
    at Parser.EventEmitter.emit (events.js:95:17)
    at onFrame (D:\nodejs\node_modules\spdy\lib\spdy\parser.js:229:12)
    at Object.parseRst (D:\nodejs\node_modules\spdy\lib\spdy\protocol\v3\protocol.js:74:3)
    at Framer.execute (D:\nodejs\node_modules\spdy\lib\spdy\protocol\v3\framer.js:59:14)
    at Parser.execute (D:\nodejs\node_modules\spdy\lib\spdy\parser.js:223:19)
    at Parser.write [as _write] (D:\nodejs\node_modules\spdy\lib\spdy\parser.js:118:8)
    at D:\nodejs\node_modules\spdy\lib\spdy\parser.js:132:12
    at Parser.execute (D:\nodejs\node_modules\spdy\lib\spdy\parser.js:208:5)
    at Parser.write [as _write] (D:\nodejs\node_modules\spdy\lib\spdy\parser.js:118:8)

请帮我解决这个错误,这是因为连接不持久吗?

1 个答案:

答案 0 :(得分:0)

我在node-spdy的旧版本(1.9.x)中看过几次这个错误。尝试升级到最新的NodeJS stable和最新的node-spdy(此时为1.10.5)。这解决了我的问题。

编辑:实际上,这还没有解决问题,我仍然在调试器中长时间使用它,基本上超时推送连接。如果我解决了这个问题,我会更新这个问题。