-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hapi and Support of HTTP/2 #2510
Comments
You can provide your own server implementation when creating a connection using the |
This comes down to: you can provide your own http2 node server implementation until node/iojs implements it right? |
it is working like express ? var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send('hello, http2!')
})
var options = {
key: fs.readFileSync('./example/localhost.key'),
cert: fs.readFileSync('./example/localhost.crt')
};
require('http2').createServer(options, app).listen(8080); |
It not work like as if I looked the socket.io sample I will try it with node-http2 module.. |
I couldn't find any resources online with a direct explanation of how to implement HTTP2 with Hapi so I'll document my solution here: var Fs = require('fs');
var Hapi = require('hapi');
var Http2 = require('http2');
var options = {
key: Fs.readFileSync('./ssl/site.key');
cert: Fs.readFileSync('./ssl/site.crt');
};
var server = new Hapi.Server();
server.connection({
listener: Http2.createServer(options),
host: 'localhost',
port: 8080,
tls: true
}); It would appear that Socket.io is NOT yet compatible with the HTTP2 library. I've submitted a bug report. The workaround is serving Socket.io from another connection with the usual HTTPS listener. |
@timelessvirtues, I've tried your sample above, but I keep getting a |
@casalot I had luck doing this: 'use strict'
const fs = require('fs')
const Hapi = require('hapi')
const Http2 = require('http2')
const server = new Hapi.Server()
let listener = Http2.createServer({
key: fs.readFileSync('./key.pem'),
cert: fs.readFileSync('./cert.pem')
})
if (!listener.address) {
listener.address = function() {
return this._server.address()
}
}
server.connection({
listener: listener,
port: '8000',
tls: true
})
server.route({
method: 'GET',
path: '/',
handler: (request, reply) => reply('hello world')
})
server.start(err => {
if (err) console.error(err)
console.log(`Started ${server.connections.length} connections`)
}) |
Hi, I am trying to add the https config tls to manifest js as below connections: [{ }, But https server is not getting started. Could anyone help me on fixing this. |
Please avoid hijacking unrelated threads when you already have yours. |
Hello,
Does Hapy have any support of HTTP/2 in natif or by plugins ?
Thank by advance
The text was updated successfully, but these errors were encountered: