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

settings.xml proxy not being honored #224

Closed
robertpatrick opened this issue Nov 11, 2022 · 16 comments
Closed

settings.xml proxy not being honored #224

robertpatrick opened this issue Nov 11, 2022 · 16 comments
Assignees

Comments

@robertpatrick
Copy link

I have an entry that looks like this in settings.xml (note I have redacted DNS names due to my company policies):

  <proxies>
    <proxy>
      <active>true</active>
      <id>myProxy</id>
      <protocol>http</protocol>
      <host><redacted-proxy-host-name/></host>
      <port>80</port>
      <nonProxyHosts>*.<redacted>.com|*.<redacted>.com</nonProxyHosts>
    </proxy>
  </proxies>

In my pom file, I have this:

            <plugin>
                <groupId>com.googlecode.maven-download-plugin</groupId>
                <artifactId>download-maven-plugin</artifactId>
                <version>1.6.8</version>
                <executions>
                    <execution>
                        <id>download-wit</id>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <uri>https://github.com/oracle/weblogic-image-tool/releases/latest/download/imagetool.zip</uri>
                            <overwrite>true</overwrite>
                            <outputFileName>imagetool.zip</outputFileName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

When I run the build, I get this:

[INFO] --- download-maven-plugin:1.6.8:wget (download-wit) @ wit-images ---
[WARNING] Could not get content
org.apache.http.conn.HttpHostConnectException: Connect to github.com:443 [github.com/192.30.255.112] failed: Operation timed out (Connection timed out)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect (DefaultHttpClientConnectionOperator.java:156)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect (PoolingHttpClientConnectionManager.java:376)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute (MainClientExec.java:393)
    at org.apache.http.impl.execchain.MainClientExec.execute (MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute (ProtocolExec.java:186)
    at org.apache.http.impl.execchain.RetryExec.execute (RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute (RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute (InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute (CloseableHttpClient.java:72)
    at org.apache.http.impl.client.CloseableHttpClient.execute (CloseableHttpClient.java:221)
    at org.apache.http.impl.client.CloseableHttpClient.execute (CloseableHttpClient.java:165)
    at com.googlecode.download.maven.plugin.internal.HttpFileRequester.download (HttpFileRequester.java:56)
    at com.googlecode.download.maven.plugin.internal.WGet.doGet (WGet.java:586)
    at com.googlecode.download.maven.plugin.internal.WGet.execute (WGet.java:443)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:301)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:211)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:165)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:157)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:121)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:127)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.net.ConnectException: Operation timed out (Connection timed out)
    at java.net.PlainSocketImpl.socketConnect (Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect (AbstractPlainSocketImpl.java:476)
    at java.net.AbstractPlainSocketImpl.connectToAddress (AbstractPlainSocketImpl.java:218)
    at java.net.AbstractPlainSocketImpl.connect (AbstractPlainSocketImpl.java:200)
    at java.net.SocksSocketImpl.connect (SocksSocketImpl.java:394)
    at java.net.Socket.connect (Socket.java:606)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket (SSLConnectionSocketFactory.java:368)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect (DefaultHttpClientConnectionOperator.java:142)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect (PoolingHttpClientConnectionManager.java:376)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute (MainClientExec.java:393)
    at org.apache.http.impl.execchain.MainClientExec.execute (MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute (ProtocolExec.java:186)
    at org.apache.http.impl.execchain.RetryExec.execute (RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute (RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute (InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute (CloseableHttpClient.java:72)
    at org.apache.http.impl.client.CloseableHttpClient.execute (CloseableHttpClient.java:221)
    at org.apache.http.impl.client.CloseableHttpClient.execute (CloseableHttpClient.java:165)
    at com.googlecode.download.maven.plugin.internal.HttpFileRequester.download (HttpFileRequester.java:56)
    at com.googlecode.download.maven.plugin.internal.WGet.doGet (WGet.java:586)
    at com.googlecode.download.maven.plugin.internal.WGet.execute (WGet.java:443)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:301)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:211)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:165)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:157)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:121)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:127)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[WARNING] Retrying (1 more)
...
[ERROR] Failed to execute goal com.googlecode.maven-download-plugin:download-maven-plugin:1.6.8:wget (download-wit) on project wit-images: IO Error: Could not get content -> [Help 1]

If I download a file from a server inside the firewall, everything works perfectly. Seems like this plugin is not honoring the settings.xml proxy settings even though the source looks like it should.

@robertpatrick
Copy link
Author

The reason this doesn't work properly is the deprecated DefaultWagonManager class' getProxyInfo(String protocol) method being used by this plugin is looking for a match of the protocol with an active proxy. With all built-in Maven plugins, an https URL will use the http proxy if there is no https proxy defined --this code does not.

                    for ( Proxy proxy : proxies )
                    {
                        if ( proxy.isActive() && protocol.equalsIgnoreCase( proxy.getProtocol() ) )
                        {
                            ...
                        }
                   }

Using the more modern plugin API, you can simple do this:

    @Parameter(defaultValue = "${settings}", readonly = true, required = true)
    private Settings settings;
    ...
    Proxy proxy = settings.getActiveProxy();

What am I missing?

@jarmoniuk
Copy link
Contributor

jarmoniuk commented Dec 2, 2022

I'm working on a PR which is doing away with WagonManager (since it's being retired anyway) and other old cruft from Maven 2 and using the new RepositoryManager from Maven 3 and 4 instead. Will give it a go and check if I can reporoduce your issue.

@jarmoniuk
Copy link
Contributor

jarmoniuk commented Dec 5, 2022

Not ready yet since I'm working on replacing the Maven 2 artefacts in the Artifact mojo (actually I'm just applying the job I did earlier for versions-maven-plugin), but the wget-related part is done. I'm actually using

Optional.ofNullable(this.session.getRepositorySession().getProxySelector())
        .flatMap(selector -> Optional.ofNullable(selector.getProxy(repository)))
        .ifPresent(proxy -> ... 

to retrieve the proxy and it does seem to use an http proxy for https targets.

@jarmoniuk
Copy link
Contributor

@longtimeago could you please assign this one to me? Thanks.

jarmoniuk added a commit to jarmoniuk/maven-download-plugin that referenced this issue Dec 5, 2022
Resolves maven-download-plugin#224

Replacing Maven 2 APIs with modern ones.
jarmoniuk added a commit to jarmoniuk/maven-download-plugin that referenced this issue Dec 9, 2022
Resolves maven-download-plugin#224

Replacing Maven 2 APIs with modern ones.
longtimeago pushed a commit that referenced this issue Dec 10, 2022
Replacing Maven 2 APIs with modern ones
@danni-beaulieu
Copy link

I have a similar issue.

@jarmoniuk
Copy link
Contributor

I think this can be closed.

@robertpatrick
Copy link
Author

@ajarmoniuk How can this be closed? There has been no new release of the plugin so any changes/fixes that might have been made are still unreleased.

@longtimeago Can we please get a new release?

@longtimeago
Copy link
Contributor

longtimeago commented Apr 30, 2023

@robertpatrick we close issues when the fix is merged, not when it's released. Because, technically (I don't encourage that in any way), you can use fixed snapshot version already.

But you are right, it's time for a release

@davidmireles
Copy link

What release is this fixed in? I've tried 1.7.1 and it still is not working through a proxy (the rest of maven downloads work fine).

@jarmoniuk
Copy link
Contributor

jarmoniuk commented Oct 11, 2023

In 1.7.1. We replaced Wagon with Maven Resolver transport. I only tested this manually against a proxy and it worked fine, including proxy auth.

However, I have no details on the particular proxy nor any logs at hand. There might be different reasons a feature might not work, so debug logs (with -X) are highly appreciated. Thanks.

@davidmireles
Copy link

davidmireles commented Oct 11, 2023

For reference testing, I try to compile/install a direct clone of this plugin: https://github.com/5aab/randoop-maven-plugin (I only change the version number for the maven-download-plugin to 1.7.1). I've tried on my windows machine with a proxy setting.xml set correctly. I've also tried building within an ubuntu development container with proxy set through docker -- everything else downloads correctly in maven, but wget cannot (slightly different logs). I can download the file in my browser, and even using wget on the command line fine. See attachments.
maven-build-log-windows.txt
maven-build-log-ubuntu.txt

I do notice in the browser it takes a while to establish connection -- is there a way to increase the read timeout?

@jarmoniuk
Copy link
Contributor

jarmoniuk commented Oct 12, 2023

Hi, both connection timeout as well as socket timeout are equal to the readTimeout plugin parameter, which is equal to 3000 milliseconds by default.

Could you try changing that and report back? Thanks.

@davidmireles
Copy link

davidmireles commented Oct 12, 2023

Ok -- I added this to the plugin configuration and that is letting me download and unpack from my docker development container now, which I believe bypasses any need for proxy settings (b/c it's set in docker).

<configuration>
	<readTimeOut>120000</readTimeOut>
</configuration>
...

But for my windows environment, same "Connect to github.com:443 [github.com/140.82.113.3] failed: Connection timed out: no further information" message. It doesn't seem to matter what I set the proxy to there, it will still timeout. And it doesn't seem to wait any longer with the readTimeOut setting.

@jarmoniuk
Copy link
Contributor

jarmoniuk commented Oct 12, 2023

It's indeed readTimeOut, my bad.

@robertpatrick
Copy link
Author

I will test this and report back.

@robertpatrick
Copy link
Author

This is definitely working now! Thanks so much

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

No branches or pull requests

5 participants