Skip to content

http2 - compat not working as http #15491

Description

@ronag

I've got a weird case where http & https works without problem. However, http2 compat does not.

In the case where I'm trying to do a PATCH, PUT or POST the request doesn't finish with http2. GET, HEAD and other "safe" methods work without problem.

Given that http2 compat should be mostly an in place replacement for http I believe this is a bug somewhere?

I'm basically using http2-proxy something like:

const http2 = require('http2')
const proxy = require('http2-proxy')
const http = require('http')
const fs = require('fs')

const proxyServer = http2
   .createSecureServer({
     cert: fs.readFileSync('./server.crt'),
     key: fs.readFileSync('./server.key'),
     allowHTTP1: true
   })
  .on('request', (req, res) => {
    proxy.web(req, res, {
      hostname: 'localhost',
      port: 7000
    }, err => {
      if (err) {
        console.error('proxy error', err)
      }
    })
  })
  .listen(6000)

const server = http
  .createServer()
  .on('request', (req, res) => {
    req
      .pipe(fs.createWriteStream(Math.random().toString()))
      .on('finish', () => {
        res.statusCode = 200
        res.end()
     })
  })
  .listen(7000)

Can't create a full repo since I don't know how to do http2 requests in node.

Activity

  1. ronag commented on Sep 20, 2017

    @ronag
    MemberAuthor

    I've tried with master.

  2. apapirovski commented on Sep 20, 2017

    @apapirovski
    Contributor

    Just an FYI, but you can't do allowHTTP1 with createServer, only createSecureServer. Not sure if that's the culprit as I'm having trouble following exactly what's going wrong. Any more debugging info or a full-source that I can run to reproduce it would be helpful. Thanks!

    Also browsers won't connect via http2 to a non-secure server.

  3. ronag commented on Sep 20, 2017

    @ronag
    MemberAuthor

    @apapirovski: It's the same with createSecureServer.

  4. ronag commented on Sep 20, 2017

    @ronag
    MemberAuthor

    A full source is going to be difficult since there are quite a lot of components involved to get it fully working.

    Have to think about how/if I can create a repo case you can run.

    What kind of debugging info would be useful?

  5. ronag commented on Sep 20, 2017

    @ronag
    MemberAuthor

    Do you have an example of how to create a http2 file upload using a client in node?

  6. apapirovski commented on Sep 20, 2017

    @apapirovski
    Contributor
  7. ronag commented on Sep 20, 2017

    @ronag
    MemberAuthor

    @apapirovski: The minimal case seems to work. So basically:

    • http2 - minimal works
    • http2 - full setup doesn't works
    • http - full setup works

    Not sure where to go from here...

  8. apapirovski commented on Sep 20, 2017

    @apapirovski
    Contributor

    Can you tell me a bit more about what's happening in the full case? How exactly is the comparison for http vs http2 being done — are you just swapping http2.createSecureServer for the equivalent http/https version or something more? How far does it get in the http2 version — does the proxied to server receive the data at all?

    Would love to help (since it sounds like there might be a legitimate issue) but it's hard without insight into what your code is doing, especially since the reduced test case works for you.

  9. ronag commented on Sep 20, 2017

    @ronag
    MemberAuthor

    I'm making a simple proxy that forwards http2 requests from Chrome to our backend storage server:

    Currently, I simply switch from http2 to http like this:

    // Doesn't work
    // const httpsServer = http2
    //   .createSecureServer({
    //     cert: readFileSync('./server.crt'),
    //     key: readFileSync('./server.key'),
    //     allowHTTP1: true
    //   })
    const httpsServer = https
      .createServer({
        cert: readFileSync('./server.crt'),
        key: readFileSync('./server.key')
      })

    When I try to upload from Chrome the requests are stuck on "pending":

    screen shot 2017-09-20 at 15 52 35
    screen shot 2017-09-20 at 15 52 44
    screen shot 2017-09-20 at 15 52 51

  10. ronag commented on Sep 20, 2017

    @ronag
    MemberAuthor

    Using nginx instead as http2->http1 proxy works. So I don't think it's a problem with the storage server.

    We're trying to replace nginx with a minimal node alternative.

  11. apapirovski commented on Sep 20, 2017

    @apapirovski
    Contributor

    I think I'm able to replicate the issue. Looking into it.

  12. apapirovski commented on Sep 20, 2017

    @apapirovski
    Contributor

    Issue is definitely in http2 and I can reproduce it with a minimal test case involving pipe. Trying to find the root cause and will submit a PR when done. Thanks for the report @ronag.

  13. added
    http2Issues and PRs related to the http2 subsystem.
    on Sep 20, 2017
  14. teerapat1739 commented on Sep 20, 2017

    @teerapat1739

    this same problem with me

  15. apapirovski commented on Sep 20, 2017

    @apapirovski
    Contributor

    @ronag I have a proposed patch in #15503. If you wouldn't mind testing it against your code, that would be absolutely amazing. I think my test case matches but it's possible there's also another issue at play.

  16. ronag commented on Sep 21, 2017

    @ronag
    MemberAuthor

    @apapirovski: Yep, that fixes it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.http2Issues and PRs related to the http2 subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions