Repository navigation
node http2 error #19406
Description
Activity
For https you should use
createSecureServerinstead ofcreateServer.Reacted by win, Trivikram Kamat and StevenReacted by winReacted by win@Trott Should the docs be updated to indicate that http2.createServer is likely not what the user wants since no browsers (that I'm aware of) support unencrypted HTTP/2 connections?
I'll defer to @nodejs/http2 and @nodejs/documentation
I think we should update the docs, yes.
This quote by @richardlau is correct
For https you should use createSecureServer instead of
createServerThe fallback mechanism to use HTTP/1.1 is not available on Http2Server as discussed in #18554
As @Trott mentioned the browsers won't support unencrypted HTTP/2 connections, butHttp2Servercan be used in certain cases - like communication between microservices if they're on the same host (a rare use case)@trivikr I typically use it all the time in tests. Spinning up tls connections costs time.
Reacted by Benjamin GruenbaumI can submit a PR to update the docs but I'm not sure what to write because it's not like it's a deprecated method, it's just not advised in most cases.
What verbiage should be used to steer users away from
createServerand towardscreateSecureServer?FWIW the initial example at the top is using
createSecureServer: https://nodejs.org/dist/latest-v9.x/docs/api/http2.html#http2_server_side_exampleThe example preface is actually incorrect because it claims to illustrate a "plain-text" HTTP/2 server. That should be changed. An additional note could be added below the example or perhaps in the
createServerdocumentation that says something along the lines of "Due to a lack of support for plain-text HTTP/2 (h2c) by the major browsers and other client-side implementations, it is recommended to usecreateSecureServer." Or something like that...Reacted by Benjamin GruenbaumFWIW the initial example at the top is using createSecureServer: nodejs.org/dist/latest-v9.x/docs/api/http2.html#http2_server_side_example
There's a lot of code samples that uses
createServerthough. Maybe a warning on the description of the method would help?@styfle Has been resolved.Thanks.
Great! I submitted #19476 which should help anyone else running into this problem.
Reacted by Benjamin Gruenbaum
http2
Running
node./server/index.jshas no error, but access to thehttps://localhost:8002failed.