使用Nodejs 10 HTTP2并表示崩溃

时间:2018-06-12 14:39:39

标签: node.js https openssl spdy

在Windows 10 64位上安装Nodejs 10.4.0。我想使用此Nodejs版本提供的闪烁新spdy切换http2模块。 这是服务器(注释,您找到以前的spdy解决方案有效):

"use strict";
const express = require("express");
const fs = require("fs");

/* Initialize application */
const app = express();
app.get("/api", function(req, res) {res.send("All OK\n");});

const options = {
    key: fs.readFileSync("./server.key"),
    cert: fs.readFileSync("./server.crt")
};

// require("spdy")
//  .createServer(options, app)
//  .listen(9999, (error) => {
//      if(error) {
//          console.error(error);
//          throw error;
//      }
//      else {
//          console.log(`\nServer started (HTTP/2)\n`);
//      }
//  });

require("http2")
    .createSecureServer(options, app)
    .listen(9999, (error) => {
        if(error) {
            console.error(error);
            throw error;
        }
        else {
            console.log(`\nServer started (HTTP/2)\n`);
        }
    });

但是当我运行它并使用curl -k https://localhost:9999/api进行连接时,服务器会崩溃并发生以下堆栈:

_http_incoming.js:95
  if (this.socket.readable)
                  ^
TypeError: Cannot read property 'readable' of undefined
    at IncomingMessage._read (_http_incoming.js:95:19)
    at IncomingMessage.Readable.read (_stream_readable.js:449:10)
    at resume_ (_stream_readable.js:888:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

和curl(版本7.60.0)回答:curl: (56) OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 0

正如在某处宣传的那样http2不是spdy HTTP / 2部分的替代品吗?谢谢!

0 个答案:

没有答案