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

leiningen cannot talk to an IPv6-only maven repository #2000

Closed
martinraison opened this issue Sep 30, 2015 · 16 comments
Closed

leiningen cannot talk to an IPv6-only maven repository #2000

martinraison opened this issue Sep 30, 2015 · 16 comments

Comments

@martinraison
Copy link

I am using a mirror to fetch my project's dependencies. This mirror is IPv6-only, which doesn't seem to be supported by leiningen (I am getting a No route to host error). I tried adding -Djava.net.preferIPv6Addresses=true to JVM_OPTS and LEIN_JVM_OPTS, without success.

Any ideas? I should add that this setup was working perfectly before, the only change is that the mirror is now IPv6-only.

@winks
Copy link
Collaborator

winks commented Sep 30, 2015

To investigate this, I just created a temporary maven repo here with only storm-core and storm-kafka in it.

Trying to dig into this, but if anyone succeeds faster...

you can test connectivity like this:

curl  'http://[2a01:238:421a:4400:58b4:be26:41f:6fde]:81/org/' -g

@martinraison
Copy link
Author

Thanks for doing this. When I specify a URL with an IPv6 address directly (with the brackets, like http://[2a01:238:421a:4400:58b4:be26:41f:6fde]:81/org/), I get this stacktrace:

Exception in thread "Thread-3" java.lang.NumberFormatException: For input string: "238:421a:4400:58b4:be26:41f:6fde]:81"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at org.apache.maven.wagon.PathUtils.port(PathUtils.java:281)
at org.apache.maven.wagon.repository.Repository.setUrl(Repository.java:147)
at org.apache.maven.wagon.repository.Repository.<init>(Repository.java:91)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.<init>(WagonRepositoryConnector.java:143)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnectorFactory.newInstance(WagonRepositoryConnectorFactory.java:142)
at org.sonatype.aether.impl.internal.DefaultRemoteRepositoryManager.getRepositoryConnector(DefaultRemoteRepositoryManager.java:346)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:453)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:216)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:193)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:281)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:186)
at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:412)
at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:240)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:333)
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:483)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
at cemerick.pomegranate.aether$resolve_dependencies_STAR_.doInvoke(aether.clj:720)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:630)
at cemerick.pomegranate.aether$resolve_dependencies.doInvoke(aether.clj:729)
at clojure.lang.RestFn.invoke(RestFn.java:2088)
at leiningen.core.classpath$fn__6725.invoke(classpath.clj:115)
at clojure.lang.AFn.applyToHelper(AFn.java:160)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invoke(core.clj:630)
at clojure.core$memoize$fn__5479.doInvoke(core.clj:6082)
at clojure.lang.RestFn.invoke(RestFn.java:436)
at leiningen.core.classpath$get_dependencies.doInvoke(classpath.clj:276)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at clojure.core$apply.invoke(core.clj:634)
at leiningen.core.classpath$resolve_dependencies.doInvoke(classpath.clj:320)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at leiningen.core.eval$prep.invoke(eval.clj:68)
at leiningen.core.eval$eval_in_project.invoke(eval.clj:352)
at leiningen.repl$server$fn__11848.invoke(repl.clj:243)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invoke(core.clj:630)
at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1868)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at clojure.core$apply.invoke(core.clj:634)
at clojure.core$bound_fn_STAR_$fn__4439.doInvoke(core.clj:1890)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.run(AFn.java:22)
at java.lang.Thread.run(Thread.java:745)

It looks like the URL is being parsed incorrectly. I don't know if that's fixed in more recent versions of maven wagon. Also in my original problem, I was using a hostname, not an IPv6 address, so the error was different (No route to host instead).

@winks
Copy link
Collaborator

winks commented Sep 30, 2015

@martinraison could you maybe post the relevant snippet where you actually configure this repo? Could be an escaping issue of the [] for all I know

@winks
Copy link
Collaborator

winks commented Sep 30, 2015

Sorry, there's already an AAAA record. just use chuck.art-core.org, it should have no A record.

@martinraison
Copy link
Author

Alright, so I tried with this in ~/.lein/profiles.clj

{:user {:mirrors {#".*" {:name "mymirror"
                     :url "http://chuck.art-core.org:81"}}}}

And did a simple lein new app testipv6, then added the [org.apache.storm/storm-core "0.9.3-rc1"] dependency as follows:

(defproject testipv6 "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.apache.storm/storm-core "0.9.3-rc1"]]
  :main ^:skip-aot testipv6.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

And after lein repl I'm getting a bunch of errors like this:

Sep 30, 2015 7:39:15 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.NoRouteToHostException) caught when processing request to {}->http://chuck.art-core.org:81: No route to host

Previously I also tried with this in ~/.lein/profiles.clj:

{:user {:mirrors {#".*" {:name "mymirror"
                         :url "http://[2a01:238:421a:4400:58b4:be26:41f:6fde]:81"}}}}

@winks
Copy link
Collaborator

winks commented Sep 30, 2015

This is what I get:

hostname:

Could not find artifact org.clojure:clojure:jar:1.7.0 in mymirror (http://chuck.art-core.org:81)
Could not find artifact org.clojure:clojure:jar:1.7.0 in mymirror (http://chuck.art-core.org:81)
Could not find artifact org.clojure:tools.nrepl:jar:0.2.10 in mymirror (http://chuck.art-core.org:81)
Could not find artifact org.clojure:tools.nrepl:jar:0.2.10 in mymirror (http://chuck.art-core.org:81)
Could not find artifact clojure-complete:clojure-complete:jar:0.2.3 in mymirror (http://chuck.art-core.org:81)
Could not find artifact clojure-complete:clojure-complete:jar:0.2.3 in mymirror (http://chuck.art-core.org:81)
Could not find artifact org.apache:apache:pom:10 in mymirror (http://chuck.art-core.org:81)
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
Exception in thread "Thread-3" clojure.lang.ExceptionInfo: Could not resolve dependencies {:suppress-msg true, :exit-code 1}

With IP:

Exception in thread "Thread-4" java.lang.NumberFormatException: For input string: "238:421a:4400:58b4:be26:41f:6fde]:81"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)

@winks
Copy link
Collaborator

winks commented Sep 30, 2015

Could be a pomegranate issue, I'm out of ideas atm :/

@martinraison
Copy link
Author

Interesting, you don't seem to have any problem with the hostname (apart from the fact that deps are missing). At least you have the parsing problem with the IP.

@winks
Copy link
Collaborator

winks commented Sep 30, 2015

Yeah I'm pretty sure we have some ipv6 parsing problem upstream. Or in lein, but I can't find where it would be.

@martinraison
Copy link
Author

For anyone having the same issue, a simple super-kludgy workaround is to use socat:

sudo socat TCP4-LISTEN:10081,fork,su=nobody TCP6:chuck.art-core.org:81

and specify http://localhost:10081 for the mirror URL. This is still far from ideal, though.

@oliviervaussy
Copy link

Seem related to https://bugs.openjdk.java.net/browse/JDK-8132520

@hypirion
Copy link
Collaborator

This also is a problem when localhost resolves to ::1 before 127.0.0.1, or if 127.0.0.1 is not present at all.

@telmich
Copy link

telmich commented May 1, 2020

ping6 - has there been any changes since the bug opening in 2015?

@technomancy
Copy link
Owner

If anyone has any ipv6 repositories we could check against, that would be nice. It's not unlikely that this has been fixed upstream since this was reported.

@marcobiscaro2112
Copy link

I believe this is fixed (not sure if on stable, but for sure in the latest main branch, commit 6e17ebb).

Maven Central now supports IPv6:

$ dig +short -t AAAA repo1.maven.org
2a04:4e42:4c::209
2a04:4e42:4d::209

Running a slightly modified version of leiningen (that depends on slf4j-simple instead of slf4j-nop):

$ export LEIN_JVM_OPTS="-Djava.net.preferIPv6Addresses=true -Dorg.slf4j.simpleLogger.defaultLogLevel=debug"
$ lein-main deps
[...]
[main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://repo1.maven.org:443][total available: 0; route allocated: 0 of 20; total allo
cated: 0 of 40]
[main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {s}->https://repo1.maven.org:443][total available: 0; route allocated: 1 of 20; tota
l allocated: 1 of 40]
[main] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {s}->https://repo1.maven.org:443
[main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to repo1.maven.org/[2a04:4e42:4d:0:0:0:0:209]:443
[main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Connecting socket to repo1.maven.org/[2a04:4e42:4d:0:0:0:0:209]:443 with timeout 1800000
[main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled protocols: [TLSv1.3, TLSv1.2]
[... handshake ...]
[main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connection established 2804:14c:193:85f2:d8d2:e695:40c:b76b:64124<->2a04:4e42:4d:0:0:0:0:209:443

@technomancy
Copy link
Owner

Awesome; thanks!

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

7 participants