2

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

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

代码:

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)

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

4

1 回答 1

0

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

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

于 2013-08-14T09:18:10.783 回答