Skip to content
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

unable to proxy http2 request #55

Open
bilalahmad99 opened this issue Apr 23, 2021 · 0 comments
Open

unable to proxy http2 request #55

bilalahmad99 opened this issue Apr 23, 2021 · 0 comments

Comments

@bilalahmad99
Copy link

im using the following code:

const proxy = require('http2-proxy');
const finalhandler = require('finalhandler');

const defaultWebHandler = (err, req, res) => {
  if (err) {
    console.error('proxy error', err)
    finalhandler(req, res)(err)
  }
}
const server = require('http2').createServer((req, res) => {
  console.log(req.headers)
  console.log(req.url)

}).listen(8080)


server.on('request', (req, res) => {
  proxy.web(req, res, {
    hostname: 'localhost',
    port: 8081
  }, defaultWebHandler)
})

and getting the error:

proxy error Error: Parse Error: Expected HTTP/
at Socket.socketOnData (_http_client.js:509:22)
at Socket.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at Socket.Readable.push (internal/streams/readable.js:223:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
bytesParsed: 0,
code: 'HPE_INVALID_CONSTANT',
reason: 'Expected HTTP/',
rawPacket: <Buffer 00 00 18 04 00 00 00 00 00 00 04 00 40 00 00 00 05 00 40 00 00 00 06 00 00 20 00 fe 03 00 00 00 01 00 00 04 08 00 00 00 00 00 00 3f 00 01>,
statusCode: 502,
connectedSocket: true,
reusedSocket: false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant