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
Testing node's new http2 native module I couldn't get express to serve requests over http2,
Using node master build with --expose-http2 (v9.0.0-pre macOS) flag:
constexpress=require('express');constapp=express();app.get('/express',(req,res)=>{res.send('Hello from express');});constserver=http2.createSecureServer({
key,
cert
},app);
When requesting /express the server crashed with the following error:
(node:80731) ExperimentalWarning: The http2 module is an experimental API.
_http_incoming.js:104
if (this.socket.readable)
^
TypeError: Cannot read property 'readable' of undefined
at IncomingMessage._read (_http_incoming.js:104:18)
at IncomingMessage.Readable.read (_stream_readable.js:431:10)
at IncomingMessage.read (_http_incoming.js:96:15)
at resume_ (_stream_readable.js:811:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Playing with it a little more - I got it to work, but I had to expose Http2ServerRequest/Response, I think it might be a good idea to expose it in general in the new http2 module.
Wrote to Douglass on the corresponding express PR will update once I get a word from him.
On Thu, Aug 31, 2017 at 10:30 AM +0300, "Benjamin Gruenbaum" <notifications@github.com> wrote:
@PiniH any ETA on when we can expect Express to work with Http2?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
I'll look at the statusMessage setter. The path one is likely better for express to handle but if you have an idea on how we can handle it on our side then ++
Playing with it a little more - I got it to work, but I had to expose Http2ServerRequest/Response, I think it might be a good idea to expose it in general in the new http2 module.
@PiniH (or anyone else), can you please explain your solution? I'm getting the same error now and I don't see how you were able to get it working.
Node 10.16
Express ~4.16.1.
My simple server:
// index.jsconstport=3000constexpress=require('express')consthttp2=require('http2')constapp=express();app.get('*',(req,res)=>{res.status(200).json({message: 'ok'})})constserver=http2.createServer(app)server.listen(port)server.on('listening',()=>console.log(`Listening on port: ${port}.`))
I'm using http2.createServer instead of http2.createSecureServer because I'm using a reverse proxy and the TLS encryption happens there, so it must not be encrypted here.
Here's what I get when I run the server locally and hit it with cURL:
and on the server I see the error reported at the top of this issue:
_http_incoming.js:95
if (this.socket.readable)
^
TypeError: Cannot read property 'readable' of undefined
at IncomingMessage._read (_http_incoming.js:95:19)
at IncomingMessage.Readable.read (_stream_readable.js:453:10)
at resume_ (_stream_readable.js:929:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
I get the same error when I deploy it. It successfully navigates the TLS handshake on the reverse proxy, then it hits my server and crashes with the same error.
If anyone can help me get unstuck here I would be very grateful. Thanks for all you do.
Activity
benjamingr commentedon Aug 7, 2017
Ping @jasnell - this is a first time contributor trying http2.
PiniH commentedon Aug 8, 2017
Playing with it a little more - I got it to work, but I had to expose Http2ServerRequest/Response, I think it might be a good idea to expose it in general in the new http2 module.
http2: Expose Http2ServerRequest/Response
PiniH commentedon Aug 31, 2017
benjamingr commentedon Aug 31, 2017
@PiniH any ETA on when we can expect Express to work with http2?
PiniH commentedon Aug 31, 2017
benjamingr commentedon Aug 31, 2017
@dougwilson
(unrelated: I have removed excess spacing created by replying via email without altering the content in PiniH's post)
MongoExpUser commentedon Aug 31, 2017
@PiniH,
Thanks for the updates.
dougwilson commentedon Aug 31, 2017
Has the change to expose the prototype been released yet?
jasnell commentedon Aug 31, 2017
Not yet. It has landed tho so it should be soon
dougwilson commentedon Aug 31, 2017
Nice :) also did anything ever happen with the two items at #14690 (comment) ?
jasnell commentedon Aug 31, 2017
I'll look at the statusMessage setter. The path one is likely better for express to handle but if you have an idea on how we can handle it on our side then ++
dougwilson commentedon Aug 31, 2017
Thanks, James :) I believe @PiniH is going to look into how / if Express.js can handle the req.path on it's side, so it may be possible.
jasnell commentedon Aug 31, 2017
Awesome. I'm excited. Let me know if there's anything else needed for this.
http2: Expose Http2ServerRequest/Response
http2: Expose Http2ServerRequest/Response
jrgleason commentedon Jun 4, 2019
Any chance of getting an example of how you got it working?
I tired...
calaway commentedon Oct 30, 2019
@PiniH (or anyone else), can you please explain your solution? I'm getting the same error now and I don't see how you were able to get it working.
My simple server:
I'm using
http2.createServerinstead ofhttp2.createSecureServerbecause I'm using a reverse proxy and the TLS encryption happens there, so it must not be encrypted here.Here's what I get when I run the server locally and hit it with cURL:
and on the server I see the error reported at the top of this issue:
I get the same error when I deploy it. It successfully navigates the TLS handshake on the reverse proxy, then it hits my server and crashes with the same error.
If anyone can help me get unstuck here I would be very grateful. Thanks for all you do.
trollkarlen commentedon Dec 6, 2019
Whats up with this, pushed to express then whats the corresponding issue there ?
Its still a issue.
/T
gaxolio commentedon Dec 10, 2020
Hi @jrgleason , any news about this problem?
Is your example working?
Please, let me know.
Many thanks
crystalfp commentedon Jan 8, 2021
Crossing fingers, with node 14.15.1 and koa 2.13.1 my application seems to work with native http2 without problems.
http2: Expose Http2ServerRequest/Response