You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repo is the best place. It's a bit difficult to follow at times, but if you track the PRs labeled http2 it should be fairly straightforward to follow along.
// Check for websocket pathif(headers[':path'].startsWith('/deepstream')){constsocket=net.connect(ds.port,ds.hostname,()=>{stream.respond();socket.pipe(stream);stream.pipe(socket);})}
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 request listener that only receives the HTTP1 requests with no HTTP2 compat. I am handling HTTP2 in stream handler and the compat request instances are just wasted.
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.
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.
Reacted by maelswarm
Reacted by patrikx3, Ali Rahbari, Pedram Emrouznejad, Bobby Johnson, Sebastiaan Deckers and 左思成
@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.
Activity
apapirovski commentedon Sep 6, 2017
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.
ronag commentedon Sep 6, 2017
@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?
jasnell commentedon Sep 6, 2017
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.
ronag commentedon Sep 6, 2017
@jasnell: Thanks! Where can I follow your progress?
jasnell commentedon Sep 6, 2017
This repo is the best place. It's a bit difficult to follow at times, but if you track the PRs labeled
http2it should be fairly straightforward to follow along.ronag commentedon Sep 6, 2017
Would something like this work?
jasnell commentedon Sep 6, 2017
It should, yes.
jasnell commentedon Sep 6, 2017
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
ronag commentedon Sep 7, 2017
@jasnell: It would be nice to be able to have
requestlistener that only receives the HTTP1 requests with no HTTP2 compat. I am handling HTTP2 instreamhandler and the compatrequestinstances are just wasted.damianobarbati commentedon May 13, 2018
WOW. That's crazy: so today you have to choose whether use "http2" OR "websockets" with node?
jasnell commentedon May 13, 2018
There is a draft spec for using websockets with http2 but none of the existing implementations support it yet.
damianobarbati commentedon May 13, 2018
Thanks @jasnell, are you referring to this? https://tools.ietf.org/html/draft-ietf-httpbis-h2-websockets-00
It says:
I'm pretty ignorant here, what's going to happen on June 22 this year?
jasnell commentedon May 13, 2018
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
p3x-robot commentedon Oct 11, 2018
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.
addaleax commentedon Oct 11, 2018
@p3x-robot #23284, which was release in v10.12.0 today, allows just that :)
jasnell commentedon Oct 11, 2018
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.
p3x-robot commentedon Oct 11, 2018
ahh, awesome, i will finally i can delete spdy, testing and thanks you so much for your info!!!!
damianobarbati commentedon Nov 11, 2018
@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.
p3x-robot commentedon Nov 11, 2018
What is SSE here?
damianobarbati commentedon Nov 11, 2018
server side events
p3x-robot commentedon Nov 11, 2018
I use socket.io but it has reconnection logic not the stream..
marcoippolito commentedon Nov 2, 2019
@jasnell James could you provide us some recent material about how to use websockets over http2?