spdy-http2 / node-spdy

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

Client does not fall back to HTTP/1.1 #315

Open dappelt opened 7 years ago

dappelt commented 7 years ago

An HTTP client using the SPDY agent does not seem to correctly fall back to HTTP/1.1. Consider this simple client using the SPDY agent, which is almost identical with the example from the readme.md:

const debug = require('debug')('myapp')
const spdy = require('spdy');
const https = require('https');
const fs = require('fs')

debug('creating SPDY agent')
var agent = spdy.createAgent({
  host: 'www.amazon.co.uk'
}).once('error', function (err) {
  debug('Spdy Error: ', err)
});

debug('sending a request')
https.get({
  host: 'www.amazon.co.uk',
  agent: agent
}, function(response) {
  debug('response');
  agent.close();
}).end();

When exeucting this code, the response callback is never executed. The debug output is:

  myapp creating SPDY agent +0ms
  myapp sending a request +14ms
  spdy:client activating fallback +12ms
  // the response callback is never executed. Instead, the node process crashes.

I assume there must be a bug in the fallback logic. Unfortunately, the node process just exists and does not print any error.