Nodejs - error request SPDY on the request

I am having problems starting the Node application. I get "TypeError: Cannot call the push method from undefined". Here is my code:

spdy.createServer(credentials, app).listen(app.get('port'), function(req, res) {
 res.push('public/js/bootstrap.min.js', {'content-type': 'application/javascript'}, function(err, stream) {
        stream.end('alert("hello from push stream!")');
      });
 res.push('public/js/jquery.min.js', {'content-type': 'application/javascript'}, function(err, stream) {
        stream.end();
      });
 res.push('public/css/bootstrap.min.css', {'content-type': 'text/css'}, function(err, stream) {
        stream.end();
      });

      // write main response body and terminate stream
      res.end('Hello World!');

console.log('Express HTTPS SPDY server listening on port ' + app.get('port'));
}   );

I am running SDPY version 1.19.2 and NodeJS version 0.10.25.

+3
source share
2 answers

Based on comment you are using HTTP / 1.1. To work, click "HTTP2 / SPDY" to work.

+1
source

Try the following:

// set the root path of Express server
app.use(express.static(__dirname+'/public');

app.use(function(req, res) {
  // your res.push code is here.
  var stream = res.push('/js/bootstrap.min.js', {'content-type': 'application/javascript'});
  stream.on('acknowledge', function() {
    console.log('stream ACK');
  });
  stream.on('error', function() {
    console.log('stream ERR');
  });
  stream.end('alert("stream SUCCESSFUL");');
  res.end('<script src="/js/bootstrap.min.js"></script>');
});

spdy.createServer(credentials, app).listen(app.get('port'));

The callback function passed to the function listen()takes no arguments. see line 49, file stream-test.js

0
source

All Articles