2013-07-20 28 views
2

1時,我能夠從https://coderwall.com/p/2gfk4w運行例子,但是當我刷新頁面中我得到下面的錯誤控制檯上的瀏覽器第二次錯誤:收到RST:運行SPDY的NodeJS例如

此示例使用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) 

請幫我解決這個錯誤,這是否發生,因爲連接不是持久的?

+0

你解決了這個問題嗎? – cYrus

回答

0

我在node-spdy的舊版本(1.9.x)中看過這個錯誤幾次。嘗試升級到最新的NodeJS stable和最新的node-spdy(目前爲1.10.5)。這已經爲我解決了這個問題。

編輯:其實,這還沒有解決問題,我仍然得到它時,長時間坐在調試器,基本上超時的推送連接。如果我解決了這個問題,我會更新這個問題。