Skip to content

Hapi-io multiple connections #44

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

Open
captainjackrana opened this issue Feb 4, 2017 · 1 comment
Open

Hapi-io multiple connections #44

captainjackrana opened this issue Feb 4, 2017 · 1 comment

Comments

@captainjackrana
Copy link

captainjackrana commented Feb 4, 2017

I'm trying to use hapi-io with a HTTPS Hapi server.
I have two connections defined so as to be able to redirect all http requests (port 80) to https

server.connection({ port: 443, host: constants.application.host, tls: tls }); // https server.connection({ port: 80, host: constants.application.host }); //http

However, i cant use hapi-io since i get the following error on registering the plugin -
error: hapi-io - multiple connections

This comes from the rule set in https://github.com/sibartlett/hapi-io/blob/master/lib/index.js#L34
if (s.connections.length !== 1) { return next('hapi-io - multiple connections'); }

How do i set it up on my server?

@dennari
Copy link

dennari commented Feb 18, 2017

Hi! server.connection returns a Server object with just a single connection. You can then do:

const https = server.connection({ port: 443, host: constants.application.host, tls: tls }); // https 
const http = server.connection({ port: 80, host: constants.application.host }); //http
https.register(hapiIO);
http.register(hapiIO)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants