Skip to content

Instantly share code, notes, and snippets.

@mrchrisadams
Last active May 1, 2020 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrchrisadams/ef7dad3af7c16fa4185e583118183074 to your computer and use it in GitHub Desktop.
Save mrchrisadams/ef7dad3af7c16fa4185e583118183074 to your computer and use it in GitHub Desktop.
Running leiningen on a VPS in an ipv6 only hosting provider. here's the repo if you want to try yourself: https://github.com/mrchrisadams/personal-site-cryogen
Exception in thread "main" java.net.SocketException: Network is unreachable (connect failed)
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
at java.base/java.net.Socket.connect(Socket.java:609)
at java.base/java.net.Socket.connect(Socket.java:558)
at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:182)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:474)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:569)
at java.base/sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:341)
at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:362)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1248)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081)
at java.base/sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:1015)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1587)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1515)
at URLConnectionReader.main(connect.java:10)
import java.net.*;
import java.io.*;
public class URLConnectionReader {
public static void main(String[] args) throws Exception {
URL yahoo = new URL("http://www.yahoo.com/");
URLConnection yc = yahoo.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
lein
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo1.maven.org:443: Network is unreachable (connect failed)
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo1.maven.org:443
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo1.maven.org:443: Network is unreachable (connect failed)
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo1.maven.org:443
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo1.maven.org:443: Network is unreachable (connect failed)
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo1.maven.org:443
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo.clojars.org:443: Network is unreachable (connect failed)
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo.clojars.org:443
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo.clojars.org:443: Network is unreachable (connect failed)
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo.clojars.org:443
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo.clojars.org:443: Network is unreachable (connect failed)
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo.clojars.org:443
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo1.maven.org:443: Network is unreachable (connect failed)
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo1.maven.org:443
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo1.maven.org:443: Network is unreachable (connect failed)
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo1.maven.org:443
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo1.maven.org:443: Network is unreachable (connect failed)
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo1.maven.org:443
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo.clojars.org:443: Network is unreachable (connect failed)
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo.clojars.org:443
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo.clojars.org:443: Network is unreachable (connect failed)
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo.clojars.org:443
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://repo.clojars.org:443: Network is unreachable (connect failed)
May 01, 2020 1:17:27 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://repo.clojars.org:443
Could not transfer artifact lein-ring:lein-ring:jar:0.12.5 from/to central (https://repo1.maven.org/maven2/): Network is unreachable (connect failed)
Could not transfer artifact lein-ring:lein-ring:jar:0.12.5 from/to clojars (https://repo.clojars.org/): Network is unreachable (connect failed)
Could not transfer artifact lein-ring:lein-ring:pom:0.12.5 from/to central (https://repo1.maven.org/maven2/): Network is unreachable (connect failed)
This could be due to a typo in :dependencies, file system permissions, or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
root@ubuntu:/var/www/blog.chrisadams.me.uk# wget -O - https://repo.clojars.org
--2020-05-01 13:18:14-- https://repo.clojars.org/
Resolving repo.clojars.org (repo.clojars.org)... 2a0a:e5c0:2:10::9765:180, 2a0a:e5c0:2:10::9765:c180, 2a0a:e5c0:2:10::9765:4180, ...
Connecting to repo.clojars.org (repo.clojars.org)|2a0a:e5c0:2:10::9765:180|:443... connected.
(defproject cryogen "0.1.0"
:description "Simple static site generator"
:url "https://github.com/lacarmen/cryogen"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.10.0"]
[ring/ring-devel "1.7.1"]
[compojure "1.6.1"]
[ring-server "0.5.0"]
[cryogen-flexmark "0.1.2"]
[cryogen-core "0.3.1"]]
:plugins [[lein-ring "0.12.5"]]
:main cryogen.core
:ring {:init cryogen.server/init
:handler cryogen.server/handler})
@mrchrisadams
Copy link
Author

ok,

I have a pretty good idea that it's the jdk that's the problem.

I'm currently using the openjdk. java --version:

openjdk 11.0.7 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.7+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.7+10, mixed mode)

I can't connect using the basic java connection when I have this.

@mrchrisadams
Copy link
Author

Hmm, I if I use java 14, and pass in -Djava.net.preferIPv6Addresses=true, the toy java class works.

java --version
java 14.0.1 2020-04-14
Java(TM) SE Runtime Environment (build 14.0.1+7)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)

I see that i'm able to connect, but I'm redirected. this is fine, as it at least shows I'm connecting to something.

java -Djava.net.preferIPv6Addresses=true connect.java 
redirect # 

I'm unable to have the same success using lein

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