spdy-http2 / node-spdy

SPDY server on Node.js
2.81k stars 196 forks source link

"Error: Received rst: 1" when I tried to push binaries #171

Closed shaunxu closed 8 years ago

shaunxu commented 10 years ago

It works when I followed the doc which pushes plain text but got "Error: Received rst: 1" when I tried to push an image binaries.

var server = spdy.createServer(options, function (req, res) {
  res.push('abc.png', { 'content-type': 'image/png' }, function (error, stream) {
    if (error) {
      console.log(error);
      return;
    }
    var buffer = fs.readFileSync('images/ad.png');
    console.log(buffer);

    stream.end(buffer);
  });

  res.end('<img src="abc.png"></img>');
});

server.listen(app.get('port'), function () {
  console.log('Express server listening on port ' + app.get('port'));
});
indutny commented 10 years ago

This is probably fine, since the browser is not required to accept all your PUSHes. Does it happen in Chromium or in Firefox? Could you please try both?

shaunxu commented 10 years ago

Just tried in Chrome 37.

Noticed that the code below causes browser cannot connect to Node, but if I specified the push file name and response file name with / prefixed, browser will show the page displayed <img src="abc.png"></img> string then Node was crashed.

indutny commented 10 years ago

Are you running this locally or on a remote server? You'll need to specify a hostname, if it is not a 127.0.0.1.

indutny commented 10 years ago

I mean res.push('https://.../abc.png')

shaunxu commented 10 years ago

I ran it on local server, I mean https://localhost:12345/. Do I need to specify the full path in res.push?

indutny commented 10 years ago

It shouldn't be required on localhost, but on a remote server - yes.