简体   繁体   中英

Boot-clj connection refused

When attempting to run Boot inside Docker, using the adzerk/boot-clj image, I receive connection refused errors.

Specifically, when the container starts up, boot is started, and then a stack trace is output. The trace (which is not easy to copy and paste between computers with no connectivity) essentially is to do with downloading - https://github.com/boot-clj/boot/releases/download/2.7.2/boot.jar - and receiving "Connection refused" errors.

I'm asking, and answering this, question in the hope that it might help someone else.

Where to start?

My main problem was with a Docker + Clojure + Boot setup, specifically when running “boot” from inside the container. Doing this spewed out a stack trace. This is where my journey begins.

I'm using the adzerk/boot-clj image. I've used it locally (OSX) without issue, the problem I experienced was in using a VM (CentOS 7) hosted within a corporate data center.

docker run -ti adzerk/boot-clj

Issuing this starts up the container, the entry point is Boot, and it starts pulling down some jars, specifically boot.jar from Github. The resulting stack trace details several problems, but the crux of it was

“java.net.ConnectException: Connection refused” (connecting to Clojars.org:443)

Hmmm…

So instead of running Boot straight away in the container, I specified the container entry point as “ —-entrypoint bash ” so I can prod around a little.

So, wget - connection refused.

What about without Docker in the way. Same thing. Connection refused.

After a little wrangling with the network team, I found that the “https_proxy” env variable needs to be set on CentOS to route traffic out to the internet. A very specific issue to me in the situation.

However….

wget is now fine, both on the host, and inside the adzerk/boot-clj container. Boot however was not.

In an effort to simplify things even more, I took Docker out of the equation entirely, and used boot locally.

Installed java-1.8.0-openjdk.x86_64, installed Boot. Same problem.

So dug around a little, and found this - https ://github.com/boot-clj/boot-bin/issues/2

This was a start. It mentions setting the BOOT_JVM_OPTIONS, specifically https.proxyHost and https.proxyPort.

It still didn't work… Arrrg.

OK, let's take Boot out of the equation.

I wrote a test harness in Java, very simple that connects to https ://clojars.org and attempts to read the index page. Copied from https ://docs.oracle.com/javase/tutorial/networking/urls/readingWriting.html, and setting the JVM_OPTS.

It still fails. “Connection refused”

…. Weird beard.

I finally stumbled on this SO - https ://stackoverflow.com/questions/43695299/java-httpurlconnection-works-on-windows-and-fails-on-linux - specifically the answer from Stephen C

“Java doesn't necessarily respect your system's default proxy settings. Since you are able to "curl" the URL on the Linux machine, the most likely explanation is that Java is not using the proxy that you have configured. The following links explains various ways to configure the proxies for Java:”

So taking the first link - https ://stackoverflow.com/questions/120797/how-do-i-set-the-proxy-to-be-used-by-the-jvm - and the answer from Leonel

I issued “ java -Dhttps.proxyHost=xxx -Dhttps.proxyPort=80 HelloWorld

I get an error, but a different one. This is progress. “Unable to tunnel through proxy”

A quick Google of this led me here: http ://www.oracle.com/technetwork/java/javase/8u111-relnotes-3124969.html - “Disable Basic authentication for HTTPS tunneling”

So updated to “ java -Dhttps.proxyHost=xxx -Dhttps.proxyPort=80 -Djdk.http.auth.tunneling.disabledSchemes=“” HelloWorld

Profit.

Info:

java -v 
openjdk version 1.8.0_144
Openjdk Runtime Environment (build 1.8.0_144-b01)
OpenJDK 64-Bit Server VM (build 25.144-b01, mixed mode)

Sorry for all my profanity Boot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM