Installed Nodejs 10.4.0 on Windows 10 64bits. I want to switch the spdy
module with the flashing new http2
provided by this Nodejs version.
Here is the server (commented you find the previous spdy
solution that works):
"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`);
}
});
But when I run it and connect using curl -k https://localhost:9999/api
the server crashes with the following stack:
_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)
and curl (version 7.60.0) answers: curl: (56) OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 0
Isn't, as advertised somewhere, http2
a drop-in replacement for spdy
HTTP/2 part? Thanks!