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] Connection fail when using behing a corporate proxy (request to https://rhda.rhcloud.com/api/v4/analysis failed, reason: read ECONNRESET) #712

Open
pgcalixto opened this issue May 16, 2024 · 7 comments

Comments

@pgcalixto
Copy link

Describe the bug
I'm behing a corporate proxy and the RHDA plugin in VSCode always fails to connect to Red Hat server, with the following message:

request to https://rhda.rhcloud.com/api/v4/analysis failed, reason: read ECONNRESET

I tried setting the proxy with all of the common procedures, such as:

  • setting http_proxy and https_proxy environment variables
  • setting VSCode's http.proxy option
  • setting VSCode's "http.proxySupport": "on" option
  • setting VSCode's http.proxyAuthorization option

None of them worked. Other plugins that need an Internet connection work with any of these settings.

To Reproduce
Steps to reproduce the behavior:

  1. Open VSCode with any Java project using Maven. I used a simple hello world project (check the files below)
  2. Open pom.xml file in the editor. When doing this, RHDA starts running
  3. The error is shown in the bottom right corner (see screenshots)

Files:

  • src/main/java/HelloWorld.java:

    import org.apache.commons.lang3.StringUtils;
    
    public class HelloWorld {
        public static void main(String[] args) {
            System.out.println("Hello World!");
            System.out.println(StringUtils.capitalize("hello world!"));
        }
    }
  • pom.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.example</groupId>
        <artifactId>hello-world</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    
        <properties>
            <java.version>21</java.version>
            <maven.compiler.source>${java.version}</maven.compiler.source>
            <maven.compiler.target>${java.version}</maven.compiler.target>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>3.14.0</version>
            </dependency>
        </dependencies>
    </project>

Expected behavior

RHDA plugin is expected to use the environment variables and/or VSCode settings to connect successfully through a corporate proxy, or to provide settings that can be customized to allow this connection.

Screenshots

image

Logs
If applicable, attach logs.

VSCode(please complete the following information):

  • OS: Windows 10 Version 22H2 Build number 19045.4291
  • VSCode version: 1.89.0
  • Dependency Analytics Version: 0.9.1

Additional context
Add any other context about the problem here.

@IlonaShishov
Copy link
Collaborator

Hi @pgcalixto,
Thank you for reaching out to us regarding this issue.
Could you please attempt the solution proposed in the following issue #671?

@pgcalixto
Copy link
Author

@IlonaShishov, I tried to set the NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable in different ways, adding it to the Windows system variables, setting it using the Powershell set command and the GUI Bash / Cygwin export key=val command, and the error persists.

@zvigrinberg
Copy link
Collaborator

zvigrinberg commented Jul 9, 2024

Hi @pgcalixto
Did you check if your corporate proxy machine not blocking ( via firewall or any equivalent software/hardware component) this server -> rhda.rhcloud.com on port 443 ( or according to your policy maybe you need to explicitly allow outbound and inbound access to/from any host on a given port) ?
please check
to quicky see if the connection is open, and if you have telnet utility installed there - kindly run the command from your corporate proxy machine

telnet rhda.rhcloud.com 443

@IlonaShishov
Copy link
Collaborator

Closing this issue due to no further comments.
Please reopen this issue if still relevant.

@pgcalixto
Copy link
Author

pgcalixto commented Jul 31, 2024

Hi! Sorry for the delay. I just upgraded the extension to v0.9.5, and it still produces the same error:

image

I was able to connect to the rhda.rhcloud.com domain, as @zvigrinberg asked:

image

@IlonaShishov, I tried to reopen the issue but wasn't able to.

@pgcalixto
Copy link
Author

pgcalixto commented Jul 31, 2024

But now I was able to dig in closer. I tried to analyze the extension code and found out that it uses a "Red-Hat Dependency Analytics Exhort JavaScript API" dependency to call the RHDA API.

By inspecting this part of the Exhort JS API code in the link below, I noticed that it uses Node's Undici fetch API to make the request:

https://github.com/RHEcosystemAppEng/exhort-javascript-api/blob/27b0d2ef68e329cecd9a4150a68c23b81558db07/src/analysis.js#L32-L40

Undici fetch does not use any proxy by default, that's the reason the RHDA extension doesn't support proxies nor the environment variables HTTP_PROXY and HTTPS_PROXY, which are a community standard.

I extracted the analysis function from the link above to a local code snippet and used axios to make the same request, but with a proxy set, and it worked!

From what I'm searching, Undici has recently developed the proxy funcionality:

Would there be any interest in the extension supporting this? A lot of companies have their networks behind a corporate proxy. I believe the code would have to be changed not in this repo, but in the linked Export JS API function.

@IlonaShishov IlonaShishov reopened this Aug 1, 2024
@IlonaShishov
Copy link
Collaborator

Hi @pgcalixto ,

Thanks for digging into this and finding a workaround! What you’ve pointed out about the Undici fetch API and proxy support is very interesting. We’ll look into this and see if we can prioritize it for future updates.

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

No branches or pull requests

3 participants