Sil*_*ley 5 https openssl node.js 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`);
}
});
Run Code Online (Sandbox Code Playgroud)
但是,当我运行它并使用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)
Run Code Online (Sandbox Code Playgroud)
和 curl(7.60.0 版)答案: curl: (56) OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 0
正如某处所宣传的那样,不是HTTP/2 部分的http2替代品spdy吗?谢谢!
| 归档时间: |
|
| 查看次数: |
1403 次 |
| 最近记录: |