question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

http2 agent doesn't work with request module

See original GitHub issue

Hi,

I’m trying to use the http2 agent with the request module. Running

var request = require("request");
var https = require("https");
var myHttp1Agent = new https.Agent({ca:ca});
request({url:"https://foo.testing/", agent:myHttp1Agent},function(error, response, body){
  console.log("request with http1 agent");
  console.log(error,body);
});

works fine but with the http2 version

var request = require("request");
var http2 = require("http2");
var myHttp2Agent = new http2.Agent({ca:ca});
request({url:"https://foo.testing/", agent:myHttp2Agent},function(error, response, body){
  console.log("request with http2 agent");
  console.log(error,body);
});

I get an exception:

_http_client.js:137
    self.agent.addRequest(self, options);
               ^

TypeError: self.agent.addRequest is not a function
    at new ClientRequest (_http_client.js:137:16)
    at Object.exports.request (http.js:31:10)
    at Object.exports.request (https.js:181:15)
    at Request.start (/home/node/app/node_modules/request/request.js:746:30)
    at Request.end (/home/node/app/node_modules/request/request.js:1357:10)
    at end (/home/node/app/node_modules/request/request.js:574:14)
    at Immediate._onImmediate (/home/node/app/node_modules/request/request.js:588:7)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

As far as I understood, http2 is supposed to be a drop in replacement for the http(s) module. So, is this a bug?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
felicienfrancoiscommented, Apr 20, 2016

@danpantry The pull request is not yet merged. This project seems no longer maintained by its owners (is it?). In the meantime you can switch to my fork : https://github.com/felicienfrancois/node-http2 which includes the fix (among others) in your package.json:

  "dependencies": {
    "http2": "felicienfrancois/node-http2",
  }
0reactions
Robbiliecommented, Jan 12, 2017

which doesnt work for me and throws a giant amount of " Error Got RST REFUSED_STREAM " when requesting a google kubernetes cluster, also no significant RPS increase over normal http

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP2_Plain in node-http2 module is not working?
The node-http2 module do support http2 over plaintext with direct connecting, it does not support HTTP/2 server with Upgrade from HTTP/1.1.
Read more >
HTTP/2 | Node.js v19.3.0 Documentation
The node:http2 module provides an implementation of the HTTP/2 protocol. It can be accessed using: const http2 = require('node:http2'); ...
Read more >
urllib.request — Extensible library for opening URLs — Python ...
The urllib.request module defines functions and classes which help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, ......
Read more >
Python's urllib.request for HTTP Requests - Real Python
Many of the issues that you tend to run into are due to the inherent ... The good news is that the urllib.request...
Read more >
HTTP/2 guide - Apache HTTP Server Version 2.4
There has been a lot written about HTTP/2 and how it works. ... request/response (KeepAlive patched the problem in HTTP 1.1 but did...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found