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

VertxFileDownloader: Support of Http Proxy Configuration #766

Closed
threadlock05 opened this issue Sep 18, 2024 · 10 comments · Fixed by #767
Closed

VertxFileDownloader: Support of Http Proxy Configuration #766

threadlock05 opened this issue Sep 18, 2024 · 10 comments · Fixed by #767
Assignees
Labels
bug Something isn't working
Milestone

Comments

@threadlock05
Copy link

Hello,

i am trying out your very cool extension for some days now and I am struggling with a proxy configuration on my system (which i can't change regarding the organizational policies).

Basically when building the project, it fails to download e.g node or npm files from the their official repositories.
So I have tried to "inject" the proxy settings on various ways, e.g. as environment variables HTTP_PROXY/HTTPS_PROXY, in the maven settings.xml, or as JVM properties on the maven run (-Dhttps.proxyHost=...). But none seemed to work.

The error/warning looks like this:
[WARNING] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManagerInstall] An error occurred 'Could not download https://registry.npmjs.org/npm/-/npm-10.2.3.tgz' during the previous Node.js install, retrying (2/5)

So my workaround is to download it manually and put the files into the .quinoa/cache directory.

When looking into the code I came along the VertxFileDownloader which is utilizing the vertx WebClient, and I was wondering if it is respecting such http proxy settings or not, as for me it seems that must be done explicitly in the code.

Maybe someone of you has any idea on this? Thanks a lot!

@melloware
Copy link
Contributor

Are you using Maven to build? You can set your Proxy at the Java level so all HTTP connections go through your proxy by editing your settings.xml file in ./m2/repository

<settings>
  ...
  <proxies>
    <proxy>
      <id>https-proxy</id>
      <active>true</active>
      <protocol>https</protocol>
      <host>proxy-host</host>
      <port>proxy-port</port>
      <username>proxy-username</username>  <!-- Optional -->
      <password>proxy-password</password>  <!-- Optional -->
      <nonProxyHosts>www.example.com|*.mycompany.com</nonProxyHosts>  <!-- Optional -->
    </proxy>
  </proxies>
  ...
</settings>

@threadlock05
Copy link
Author

threadlock05 commented Sep 18, 2024

Hi,

yes I build with "mvn clean install" and have already configured my maven settings.xml, but it seems to have no effect on the download.

For example what works for me, is to download node/npm via the maven frontend plugin:

            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.15.0</version>
                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                    </execution>
                </executions>
                <configuration>
                    <installDirectory>./.quinoa/</installDirectory>
                    <nodeVersion>v20.17.0</nodeVersion>
                    <npmVersion>10.8.2</npmVersion>
                </configuration>
            </plugin>

in the console output of maven it looks like this:

[INFO] --- frontend:1.15.0:install-node-and-npm (install node and npm) @ jtra-api --- [INFO] Found proxies: [http_proxy{protocol='http', host='proxy.....', port=8080, nonProxyHosts='*....|10.*'}, https_proxy{protocol='https', host='proxy....', port=8080, nonProxyHosts='*...|10.*'}] [INFO] Installing node version v20.17.0 [INFO] Copying node binary from ..\m2\com\github\eirslett\node\20.17.0\node-20.17.0-win-x64.exe to my-project\.quinoa\node\node.exe [INFO] Installed node locally. [INFO] Installing npm version 10.8.2 [INFO] Unpacking ...\m2\com\github\eirslett\npm\10.8.2\npm-10.8.2.tar.gz into my-project\.quinoa\node\node_modules [INFO] Installed npm locally.

so somehow i am think that the issue is related to the VertxFileDownloader class

@melloware
Copy link
Contributor

yep you might be correct.

@melloware melloware self-assigned this Sep 18, 2024
@melloware melloware added the bug Something isn't working label Sep 18, 2024
@melloware melloware added this to the 2.4.8 milestone Sep 18, 2024
melloware added a commit to melloware/quarkus-quinoa that referenced this issue Sep 18, 2024
@melloware
Copy link
Contributor

PR submitted!

@melloware
Copy link
Contributor

@all-contributors add @threadlock05 for bug

Copy link
Contributor

@melloware

I've put up a pull request to add @threadlock05! 🎉

@melloware
Copy link
Contributor

2.4.8 should be in Maven Central soon if you want to try it again

@threadlock05
Copy link
Author

threadlock05 commented Sep 19, 2024

Hi, thanks a lot for the quick response and fix.
It works now for me when doing my build with "mvn clean install -Dhttp.proxyHost=myproxy.org -Dhttp.proxyPort=8080"
or when directly configuring the proxy as systemProperties for the quarkus-maven-plugin, e.g.

                <artifactId>quarkus-maven-plugin</artifactId>
                <version>${quarkus.platform.version}</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <goals>
                            <goal>build</goal>
                            <goal>generate-code</goal>
                            <goal>generate-code-tests</goal>
                            <goal>native-image-agent</goal>
                        </goals>
                        <configuration>
                            <systemProperties>
                                <http.proxyHost>myproxy.org</http.proxyHost>
                                <http.proxyPort>8080</http.proxyPort>
                            </systemProperties>
                        </configuration>
                    </execution>
                </executions>

so thats quite fine for me.
the only thing I am wondering that it is not taking the proxy configuration of the settings.xml into account, maybe that is also just an issue on my side.

@melloware
Copy link
Contributor

I guess I have to study how maven works but I assumed they were simply setting those System Properties so it would be picked up?

@melloware
Copy link
Contributor

@threadlock05 ok so those .m2 settingsa are only available to Maven itself and Maven Plugins so it would require hooking into Maven which I don't want to do since Quarkus also fully supports Gradle (yuck). So your solution is a good one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants