Skip to content

Custom http agent support #810

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

Merged
merged 6 commits into from
Apr 10, 2019
Merged

Custom http agent support #810

merged 6 commits into from
Apr 10, 2019

Conversation

delvedor
Copy link
Member

@delvedor delvedor commented Apr 9, 2019

With this pr we add the support for a custom http(s) agent passed as a parameter instead of the http agent options.
In any case, you will use the same agent configuration option.

const { Agent } = require('http')
const { Client } = require('@elastic/elasticsearch')

const client = new Client({
  node: 'http://localhost:9200',
  agent: new Agent({ ... })
})

client.info(console.log)

Related: #808 #809

@endymonium
Copy link

Tested it locally, looks good, thanks 👍

var proxyingAgent = require('proxying-agent').create(
      'http://proxy:8080', 
      'https://<redacted>.eu-central-1.aws.cloud.es.io');
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ 
      node: 'https://<redacted>.aws.cloud.es.io',
      agent: proxyingAgent
})

@delvedor
Copy link
Member Author

delvedor commented Apr 9, 2019

I've updated the implementation, now if you want to use a custom http agent you should pass it via a function return.
The reason is that not every http agent in userland inherits from the Node.js core one.

@delvedor delvedor merged commit 2919f93 into master Apr 10, 2019
@delvedor delvedor deleted the custom-http-agent branch April 10, 2019 09:13
delvedor added a commit that referenced this pull request Apr 10, 2019
delvedor added a commit that referenced this pull request Apr 10, 2019
delvedor added a commit that referenced this pull request Apr 10, 2019
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

Successfully merging this pull request may close these issues.

2 participants