Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

HTTP/2 server support? #68

Closed
IngwiePhoenix opened this issue May 15, 2015 · 5 comments
Closed

HTTP/2 server support? #68

IngwiePhoenix opened this issue May 15, 2015 · 5 comments

Comments

@IngwiePhoenix
Copy link
Contributor

I just wondered if there is a way that a SocketCluster server would be able to use a HTTP/2 server. I saw one on NPM that supports the actual http API.

https://www.npmjs.com/package/http2

@jondubois
Copy link
Member

@IngwiePhoenix Yes, good idea. I will look into it this weekend.

@jondubois
Copy link
Member

@IngwiePhoenix I would prefer to wait a bit longer before allowing HTTP2 support in SC.
I spent some time reading discussions in Node.js issues section and it seems that it's still undecided how and when HTTP2 will be integrated into core.

I think we could in theory add support for HTTP2 before it becomes part of Node.js core, but looking through the issues list: https://github.com/molnarg/node-http2/issues - It seems like the http2 module is still in its early stages. I will keep an eye on the project and when it looks like it's stable enough for production use, we can allow people to use it instead of the regular http1.1 - Probably by setting the prototocol option of SC to 'http2'.

We can leave this issue open as a reminder to check up on it from time to time - It might not be too far off.

@jondubois
Copy link
Member

At first glance, it looks like it may be possible to make a small change to SC to allow providing a custom server object (this could be a HTTP2 server or SPDY server or whatever).

I will try to look into this sometime next week.

@jondubois
Copy link
Member

When instantiating the main SocketCluster instance (in server.js), you can now pass an optional 'httpServerModule' - It should be a string (module name/path). So if you want to use the http2 module, you can set it to 'http2'. You can specify any module but it has to conform to the standard Node.js http API (which http2 does).

Note that http2 doesn't appear to work with express yet though, so if your SC worker uses express then it will throw a weird error. See molnarg/node-http2#100

Use at your own risk :p

@ayZagen
Copy link

ayZagen commented Dec 24, 2018

@jondubois http2 is stable now. I tried httpServerModule option but it seems not working.

EDIT: I found that we could override createHTTPServer in workers. Still http2 is not working because of websocket libraries lacking support of it. Did some research and created a new issue for it. Please see @/SocketCluster/socketcluster#465

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

No branches or pull requests

3 participants