-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
http2 websocket #15230
Comments
Hi @ronag, you can't use websockets with http2. See https://daniel.haxx.se/blog/2016/06/15/no-websockets-over-http2/ for more info. |
@apapirovski: Yes, so somehow I have to start a http1 server on the same port? How does e.g. nginx do it to support both on the same port? |
http/2 does have a fallback mechanism that allows http1 and http2 on the same port; for right now the impl in core depends on having a TLS connection and using ALPN to differentiate. See the test case in https://github.com/nodejs/node/blob/master/test/parallel/test-http2-https-fallback.js It's a bit rough still. We're still working through the details of this particular bit. |
@jasnell: Thanks! Where can I follow your progress? |
This repo is the best place. It's a bit difficult to follow at times, but if you track the PRs labeled |
Would something like this work? // Check for websocket path
if (headers[':path'].startsWith('/deepstream')) {
const socket = net.connect(ds.port, ds.hostname, () => {
stream.respond();
socket.pipe(stream);
stream.pipe(socket);
})
} |
It should, yes. |
wait... sorry, I got your threads mixed up... this should work for proxying in general, but not for websockets. There is no way to implement websockets on the same connection as http2 |
@jasnell: It would be nice to be able to have |
WOW. That's crazy: so today you have to choose whether use "http2" OR "websockets" with node? |
There is a draft spec for using websockets with http2 but none of the existing implementations support it yet. |
Thanks @jasnell, are you referring to this? https://tools.ietf.org/html/draft-ietf-httpbis-h2-websockets-00
I'm pretty ignorant here, what's going to happen on June 22 this year? |
All ietf internet draft versions have a six month life span to discourage things from becoming too stale. I would expect an updated draft on or before then |
with spdy it works out of the box with https/2, websocket, it is werid nodejs does not support with http2 with websocket. we use socket.io for everything. |
@p3x-robot #23284, which was release in v10.12.0 today, allows just that :) |
The spec to enable websockets over http2 was just finished by the ietf working group in early September. Support for that just landed in nghttp2 about two weeks ago, and we've landed the basic mechanism in core just this week. I have a working prototype using the ws module. Progress is being made. |
ahh, awesome, i will finally i can delete spdy, testing and thanks you so much for your info!!!! |
@jasnell will websocket over http2 have auto-reconnection logic built-in like SSE? Just wondering, because if they are using the same stream then this should be the case. |
What is SSE here? |
server side events |
I use socket.io but it has reconnection logic not the stream.. |
@jasnell James could you provide us some recent material about how to use websockets over http2? |
Since http2 does not have the
upgrade
event maybe the docs should mention how to combine a node http2 server with websockets?The text was updated successfully, but these errors were encountered: