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

Http requests fail in node.js v0.11 #106

Closed
analog-nico opened this issue May 19, 2014 · 2 comments
Closed

Http requests fail in node.js v0.11 #106

analog-nico opened this issue May 19, 2014 · 2 comments

Comments

@analog-nico
Copy link

The following code succeeds in node.js 0.10.28:

var client = require('elasticsearch').Client();
client.indices.exists({
  index: 'fancyindex'
}).then(function (response) {
  // ...
});

However, in node.js v0.11.13 it fails.

I debugged it and found out that when calling node's http.request(...) inside the function HttpConnector.prototype.request an agent is passed with the request parameters that is somehow incompatible.

When I set reqParams.agent = undefined; before the this.hand.request(reqParams, ...) call then the request succeeds again. Probably, the forever-agent you are depending on is the culprit?

@spalger
Copy link
Contributor

spalger commented May 19, 2014

Possibly.

As 0.11 is unstable by definition, I haven't taken time to solve why it doesn't work. A quick look at the 0.11.13 docs imply that the Agent's in 0.11 serve the same purpose as forever-agent, so you could probably use this custom HTTP Connector if you would like to use KeepAlive connections and node 0.11

@spalger spalger closed this as completed May 19, 2014
@analog-nico
Copy link
Author

Thanks for the info.

FYI: The signature of agent.addRequest(...) as it is implemented by CustomForeverAgent.prototype.addRequest and called from the native http module changed from passing the arguments req, host, port (node.js v0.10) to passing just req, options (node.js v0.11). options actually is reqParams from your this.hand.request(reqParams, ...) call.

This breaking change is already known to the author of forever-agent.

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

2 participants