I am able to run example from https://coderwall.com/p/2gfk4w but when I refresh page in the browser second time I am getting below error on console
This example uses response.push for spdy - Example code and Error are below:
Code:
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:
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)
Please help me to solve this error, is this happening because the connection is not persistent?
I've seen this error a few times in older versions (1.9.x) of node-spdy. Try upgrading to the newest NodeJS stable and the latest node-spdy (at this time, 1.10.5). That has resolved the issue for me.
Edit: Actually, this has not resolved the issue, I still get it when sitting in the debugger for a long time, essentially timing out a push connection. I will update this question if I fix the issue.