在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部分的替代品吗?谢谢!