Running SBT behind proxy - bash

I am trying to run SBT example behind corporate proxy.
sbt new sbt/scala-seed.g8
I set proxy as per instructions:
export SBT_OPTS="$SBT_OPTS -Dhttp.proxyHost=myusername:mypassword#correcthost -Dhttp.proxyPort=correctport -Dhttps.proxyHost=myusername:mypassword#correcthost -Dhttps.proxyPort=correctport"
Error that is showing:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scala-sbt.sbt-giter8-resolver#sbt-giter8-resolver_2.12;0.1.3: public: unable to get resource for org/scala-sbt/sbt-giter8-resolver#sbt-giter8-resolver_2.12;0.1.3: res=https://repo1.maven.org/maven2/org/scala-sbt/sbt-giter8-resolver/sbt-giter8-resolver_2.12/0.1.3/sbt-giter8-resolver_2.12-0.1.3.pom: java.net.UnknownHostException: myusername:mypassword#correcthost: invalid IPv6 address
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] java.lang.RuntimeException: Retrieval of org.scala-sbt.sbt-giter8-resolver:sbt-giter8-resolver:0.1.3 failed.
Why is it throwing invalid IPv6 address error?
How to properly set proxy for SBT?
Thanks.

As far as I can tell, the -Dhttps.proxyHost=myusername:mypassword#correcthost shouldn't be formatted like that. Instead you provide the following setup in your ~/.profile and you'll have to set the variables of course:
export SBT_OPTS="-Dhttp.proxyHost=${PROXY_HOST} -Dhttp.proxyPort=${PROXY_PORT} -Dhttps.proxyHost=${PROXY_HOST} -Dhttps.proxyPort=${PROXY_PORT} -Dhttp.proxyUser=$USER -Dhttp.proxyPassword=$PASS -Dhttps.proxyUser=$USER -Dhttps.proxyPassword=$PASS"
So the user and password are provided in their own settings override (-Dhttps.proxyUser/Password).

If you are using a Proxy which requires authentication, I have a solution for you :)
SBT has a very hard time handling proxy requiring authentication. The solution is to bypass this authentication, if you cannot turn off your proxy on demand (corporate proxy for example). To do so, I suggest you use a squid proxy, and configure it with your username and password to access your corporate proxy. See : https://doc.ubuntu-fr.org/squid Then, you can set JAVA_OPTS or SBT_OPTS environment variables so that SBT connects to your own local squid proxy instead of your corporate proxy :
export JAVA_OPTS = "-Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128 -Dhttp.proxyHost=localhost -Dhttp.proxyPort=3128"
(just c/c this in your bashrc without modifying anything and it should work fine).
The trick is that Squid Proxy does not require any authentication, and acts as an intermediate between SBT and your other proxy.
If you have troubles in applying this advise, please let me know.
Regards,
Edgar

Related

Spring Tool Suite 4.8.0.RELEASE - Network connections proxy settings

When I run any maven command with specified http and https proxy address and port as below:
mvn <command> -Dhttps.proxyHost=<MY.PROXY.HOST.ADDRESS> -Dhttps.proxyPort=<MY_PROXY_PORT> -Dhttp.proxyHost...
It's running without any error.
I want to set those configurations as default for my STS network connections and select the manual Active Provider (see attached screenshot for my configurations),
I think it's not related to the STS versions because I faced the same problem with 3.8 and 4.6 version. Anyway, Here is my STS version
Now, when I try the same maven command without proxy and port arguments, the maven command fails due to a network connection error.
[ERROR] unable to read java.net.ConnectException: Connection timed out

gcloud login network connection failed issue

I tried to connect gcloud with gcloud init. I got Network connection error.
I tried to fix with Network connection problems in Google Cloud SDK while I have access to google or website like google app engine in my browser
gcloud config set proxy/type socks5
gcloud config set proxy/address 127.0.0.1
gcloud config set proxy/port 1086
But it still does not work for me.
My log is:
Welcome! This command will take you through the configuration of gcloud.
Settings from your current configuration [default] are:
core:
disable_usage_reporting: 'False'
proxy:
address: 127.0.0.1
port: '1080'
type: socks5
Pick configuration to use:
[1] Re-initialize this configuration [default] with new settings
[2] Create a new configuration
[3] Switch to and re-initialize existing configuration: [cindy]
Please enter your numeric choice: 1
Your current configuration has been set to: [default]
You can skip diagnostics next time by using the following flag:
gcloud init --skip-diagnostics
Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.
ERROR: Reachability Check failed.
Cannot reach https://www.google.com (error)
Cannot reach https://accounts.google.com (error)
Cannot reach https://cloudresourcemanager.googleapis.com/v1beta1/projects (error)
Cannot reach https://www.googleapis.com/auth/cloud-platform (error)
Cannot reach https://dl.google.com/dl/cloudsdk/channels/rapid/components-2.json (error)
Network connection problems may be due to proxy or firewall settings.
Current effective Cloud SDK network proxy settings:
type = socks5
host = 127.0.0.1
port = 1080
username = None
password = None
What would you like to do?
[1] Change Cloud SDK network proxy properties
[2] Clear all gcloud proxy properties
[3] Exit
It is due to redirection from goolge account to localhost for acquiring token Try to login using firefox
Considering the error and mainly the following part of the error, it seems that you are facing issues with your proxy and firewall settings and configuration.
Network connection problems may be due to proxy or firewall settings.
Due to this error, you need to configure your SDK to be used with proxy and firewall. I would recommend you to take a look at the documentation Configuring Cloud SDK for use behind a proxy/firewall, to get more information and steps on how to achieve it and avoid the error that you are facing.
Besides that, I could find the below two posts from the Community, of users that are facing similar cases that you are facing.
ERROR: Reachability Check failed. #51
gcloud utility not working #25
Let me know if the information helped you!
For the people who still have this problem.
Try to use IPV4 first as IPV6 is still buggy for many systems.
For Linux, you can just uncomment or add the following line in /etc/gai.conf file:
precedence ::ffff:0:0/96 100
For other systems, you can google the set-up

sbt 0.13 on Windows - Cannot Access Repositories

I've gone through almost everything related to installing sbt on Window on stackoverflow (there are quite a few people having the same problem with me). However, the answer seems unclear/unreproducible on my machine.
Here is what I did:
Download sbt-0.13.13 on this site
Install it successfully and set the PATH
Try sbt version to see if it is installed successfully. Error
returned (as at the end of this post)
A few things we should know:
I already have JDK
I don't use Proxy on my computer (tested with netsh winhttp show
proxy)
Someone said it is because sbt doesn't support ASCII character - but
the solution wasn't clear
problems summary
WARNINGS
module not found: org.fusesource.jansi#jansi;1.11
local: tried
C:\Users\buidu\.ivy2\local\org.fusesource.jansi\jansi\1.11\ivys\ivy.xml
-- artifact org.fusesource.jansi#jansi;1.11!jansi.jar:
C:\Users\buidu\.ivy2\local\org.fusesource.jansi\jansi\1.11\jars\jansi.jar
==== Maven Central: tried
https://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.11/jansi-1.11.pom
-- artifact org.fusesource.jansi#jansi;1.11!jansi.jar:
https://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.11/jansi-1.11.jar
==== typesafe-ivy-releases: tried
https://repo.typesafe.com/typesafe/ivy-releases/org.fusesource.jansi/jansi/1.11/ivys/ivy.xml
==== sbt-ivy-snapshots: tried
https://repo.scala-sbt.org/scalasbt/ivy-snapshots/org.fusesource.jansi/jansi/1.11/ivys/ivy.xml
UNRESOLVED DEPENDENCIES
org.fusesource.jansi#jansi;1.11: not found
Server access Error: Permission denied: connect url=https://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.11/jansi-1.11.pom
Server access Error: Permission denied: connect url=https://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.11/jansi-1.11.jar
Server access Error: Permission denied: connect url=https://repo.typesafe.com/typesafe/ivy-releases/org.fusesource.jansi/jansi/1.11/ivys/ivy.xml
Server access Error: Permission denied: connect url=https://repo.scala-sbt.org/scalasbt/ivy-snapshots/org.fusesource.jansi/jansi/1.11/ivys/ivy.xml
You could try to configure the use of IPV4 (not IPV6), as described in the accepted answer for this question:
Error while importing sbt project , Server Access error, unresolved dependencies
setx _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true
I was struggling with the same for a week. The only thing, that helped, was to uninstall sbt from the default location (c:\Program Files(x86)\sbt) and reinstall it to some location without spaces (I've installed it to d:\sbt).
Did you try taking a look in your sbt repositories file (likely to be c:\users\.sbt\repositories, and specifying http:// instead of https:// ?

Mulesoft - SFTP Component to go through SOCKS Proxy

I was hoping someone could help.
I am trying to sftp to a remote server that is behind a firewall. I have a proxy setup and can sftp via the unix terminal succesfully. However when using mulesofts SFTP connector I get a timeout. From research it looks like this is because it is run on the JVM.
Mule comes with wrapper.conf to update any jvm settings so I have set the following settings:
wrapper.java.additional.15=-DsocksProxyHost:hostname
wrapper.java.additional.16=-DsocksProxyPort=1080
When I do this the Mule service no longer runs and get the following error:
WrapperManager Error: Unexpected exception opening backend socket: java.net.SocketException: Can't connect to SOCKS proxy:Invalid argument or cannot assign requested address
Hopefully someone can assist.
Thank you.
Perhaps typo in the
-DsocksProxyHost:hostname
Should be = rather than :.
The port is unnecessary, 1080 is the default. Documentation is here, see section 2.4 for SOCKS
http://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html

How to specify proxy credentials for lagom / activator / sbt?

I am trying out Lagom from Lightbend, using the my-first-system template from the GettingStarted page.
I am on Windows 10, and behind a corporate proxy.
Activator fails to download some dependencies due to missing credentials for the proxy. I have set the HTTP_PROXY environment variable.
The following error is reported by activator:
[info] Updating {file:/E:/Projects/LagomHelloWorld/my-first-system/project/}my-first-system-build...
[info] Resolving com.lightbend.lagom#lagom-sbt-plugin;1.0.0 ...
[error] Server access Error: Connection timed out: connect url=https://repo.typesafe.com/typesafe/ivy-releases/com.lightbend.lagom/lagom-sbt-plugin/scala_2.10/sbt_0.13/1.0.0/ivys/ivy.xml
[error] Server access Error: Connection timed out: connect url=https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.lightbend.lagom/lagom-sbt-plugin/scala_2.10/sbt_0.13/1.0.0/ivys/ivy.xml
[error] Server access Error: Connection timed out: connect url=https://repo1.maven.org/maven2/com/lightbend/lagom/lagom-sbt-plugin_2.10_0.13/1.0.0/lagom-sbt-plugin-1.0.0.pom
[error] Unable to find credentials for [ # <proxy-ipv4-addr> ].
[warn] module not found: com.lightbend.lagom#lagom-sbt-plugin;1.0.0
Note: The error message contains the actual IPv4 address, not the substitute I show above.
Where should I specify the user id and password for the proxy?
How can I do that in a secure way?
Activator should check for system properties, in your case
#-Dhttp.proxyUser=PUT YOUR PROXY USER HERE
#-Dhttp.proxyPassword=PUT YOUR PROXY PASSWORD HERE
in a file ~/.activator/activatorconfig.txt.
This is described in detail in the FAQ section on https://www.lightbend.com/activator/docs
Scroll down to the section "Behind a Proxy".

Resources