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.

Wrong target reported when using AutoDependencyTracking and HTTP_PROXY environment variable

See original GitHub issue

Follow up after #689 and #692.

The problem still persists, that when using request library together with HTTP_PROXY setting, all dependency requests that go through proxy have target of 443 (this are https requests).

Options object in HttpDependencyParser._getUrlFromRequestOptions is of following structure:

{
  host: "proxy-host",
   port: 3128,
   proxyAuth: null,
   headers: {
     Accept: "application/json",
     host: "destination-host:443",
   },
   method: "CONNECT",
   path: "destination-host:443",
   agent: false,
 }

And after url.parse in line 141, the protocol is “destination-host” and host is 443.

Anyway - the result of _getUrlFromRequestOptions function will be in this case still PROXY host, not the real one.

On the other hand, when I debug through public static trackRequest(client: TelemetryClient, telemetry: Contracts.NodeHttpDependencyTelemetry) {

I see requestParser.url set proxy host, but when callback is called telemetry.request.on('response', (response: http.ClientResponse) => { then requestParser.url is already set to target host and port, but without protocol. Can’t find place, where it’s actually changed.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
wiktorncommented, Jan 13, 2021

One question regarding migration to other libraries. As we will then use some other agent (that supports proxy), I’ve checked the node docs, and cant see that http.agent.protocol is part of the spec, so I fear, that whichever other library we will use, the above code will still fail, as other agents will also not provide this information.

On the other hand, I that recent versions of node (Added in: v14.5.0, v12.19.0) there is added field - request.protocol - maybe this is the place, where Azure Insights should also look. As far as I’ve tested (on v12.20.1), in both above cases request.protocol is set, though to this suspicious value https: (with colon at the end).

0reactions
hectorhdzgcommented, Jan 13, 2021

Adding support for whatever is the current way of retrieving in native http/s make perfect sense, will update the code to use request.protocol as well when available

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disable automatic proxy detection from environment variables
Use `false` to disable proxies, ignoring environment variables. // `auth` indicates that HTTP Basic auth should be used to connect to the ...
Read more >
How do I use Maven through a proxy? - Stack Overflow
For details of setting up a proxy for Maven, see the mini guide. ... The http part of the target has to be...
Read more >
Amazon ECS container agent configuration
The Amazon ECS container agent supports a number of configuration options, most of which should be set through environment variables.
Read more >
Troubleshoot pipeline runs - Azure DevOps - Microsoft Learn
Learn how to troubleshoot pipeline runs in Azure Pipelines and Team Foundation Server.
Read more >
Dependency Scanning - GitLab Docs
Implicitly using the auto dependency scanning provided by Auto DevOps. ... scanning report, compares the found vulnerabilities between the source and target ...
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