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

[BUG] Custom proxy with error "Expecting a valid host string in proxy settings, but found" #1329

Closed
hintdesk opened this issue May 16, 2024 · 1 comment · Fixed by #1331
Closed
Assignees

Comments

@hintdesk
Copy link

hintdesk commented May 16, 2024

Description/Screenshot
In my company we have set a corporate proxy. To connect to Internet the application has to use this proxy.
The proxy has the format of "http://proxy.companyname.i:port".
I have set that proxy over env variable http_proxy und https_proxy. Currently I receive this error

Configuring Azure AppInsights
Failed to start default client: [object Error]{ stack: 'Error: Expecting a valid host string in proxy settings, but found "proxy.companyname.i".
2024-05-15T13:03:52.037201912Z at getUrlFromProxySettings (/app/node_modules/@azure/core-rest-pipeline/dist/commonjs/policies/proxyPolicy.js:129:15)
at proxyPolicy (/app/node_modules/@azure/core-rest-pipeline/dist/commonjs/policies/proxyPolicy.js:177:11)
2024-05-15T13:03:52.037210399Z at createPipelineFromOptions (/app/node_modules/@azure/core-rest-pipeline/dist/commonjs/createPipelineFromOptions.js:30:61)
at createClientPipeline (/app/node_modules/@azure/core-client/dist/commonjs/pipeline.js:16:73)
at createDefaultPipeline (/app/node_modules/@azure/core-client/dist/commonjs/serviceClient.js:157:51)
at new ServiceClient (/app/node_modules/@azure/core-client/dist/commonjs/serviceClient.js:53:45)
at new ApplicationInsightsClient (/app/node_modules/@azure/monitor-opentelemetry-exporter/dist/index.js:1824:9)
2024-05-15T13:03:52.037227236Z at new HttpSender (/app/node_modules/@azure/monitor-opentelemetry-exporter/dist/index.js:2782:34)
at new AzureMonitorMetricExporter (/app/node_modules/@azure/monitor-opentelemetry-exporter/dist/index.js:3591:24)
at new MetricHandler (/app/node_modules/@azure/monitor-opentelemetry/dist/index.js:3220:31)', message: 'Expecting a valid host string in proxy settings, but found "proxy.companyname.i".', name: 'Error' []
AppInsights ProxyHttpUrl: http://proxy.companyname.i:port
AppInsights new ProxyHttpUrl: http://proxy.companyname.i:port
`

Steps to Reproduce

  • SDK Version [e.g. 22]: 3.0.0
  • How you initialized the SDK:

if (process.env.APPLICATIONINSIGHTS_CONNECTION_STRING) {
console.log('Configuring Azure AppInsights');
appInsights
.setup(process.env.APPLICATIONINSIGHTS_CONNECTION_STRING)
.setAutoDependencyCorrelation(false)
.setAutoCollectRequests(true)
.setAutoCollectPerformance(false, false)
.setAutoCollectExceptions(true)
.setAutoCollectDependencies(false)
.setAutoCollectConsole(false)
.start();
}

Expected behavior
What should I have to do to tell ApplicationInsights SDK that "proxy.companayname.i:port" is a valid host?

@JacksonWeber
Copy link
Contributor

JacksonWeber commented May 20, 2024

@hintdesk This looks to be related to Node.js's URL class and how it parses URLs. ApplicationInsights 3.X SDK relies on the Azure SDK's core-rest-pipeline, which in turn parses the proxy URL here. While this works fine for the string http://proxy.companyname.i, the method fails on proxy.companyname.i (which is what the method receives there as it's given the proxy's host string instead of the full URL). I'll file an issue on the core-rest-pipeline side as it seems like this issue would affect anyone attempting to pass in valid proxy URLs with multiple . characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants