Closed
Description
🐛 Bug Report
The feature added to replace createNodeAgent doesnt work as expected
#810
When proxying the requests over socks5 through an ssh tunnel the library fails to find the host
After some debugging I found where the issue is but I don't have enough understanding of the library to apply it.
On the connection pool urlToHost
new URL will transform https://myelastic:443 and remove the port, since it is the https protocol
When running the request the host is:
host:
[ 'Host',
'myelastic:80' ] } }
If I do the following the request is done successfully:
const requestParams = this.buildRequestObject(params)
requestParams.port = undefined
If requestParams.port = ''
, https.request host port will default to 80
To Reproduce
Version 6.X
const { Client } = require('@elastic/elasticsearch')
const SocksProxyAgent = require('socks-proxy-agent')
const client = new Client({
node: 'https://myelasticsearch:443',
agent: () => new SocksProxyAgent('socks5://127.0.0.1:7766')
})
client.search().then(response => {
console.log(response)
})
Expected behavior
Version 16.X
const { Client } = require('elasticsearch')
const SocksProxyAgent = require('socks-proxy-agent')
const client = new Client({
host: 'https://myelasticsearch:443',
createNodeAgent: () => new SocksProxyAgent('socks5://127.0.0.1:7766')
});
client.search().then(response => {
console.log(response)
})
or the same as in the reproduce with:
requestParams.port = undefined
Your Environment
- node version: v10.14.0
@elastic/elasticsearch
version: >=6.4.3- os: Mac
Metadata
Metadata
Assignees
Labels
No labels