Using spring cli behind proxy results in "Connection refused" error - spring

I am struggling to get spring cli running behind our corporate proxy. I read some suggestions in spring blogs on how to set the proxy and tried to follow, but w/o any success so far.
I tried the following
set http.proxyHost, http.proxyPort, http.proxyUser, http.proxyPassword as windows env variable
set corresponding variables for https as well
set JAVA_OPTS env. variable with -D...
verified that JAVA_OPTS variables are correctly picked up by setting debug on
Based on the above settings, the startup script is actually using the below command to run the spring cli
"C:\Program Files\Java\jdk1.8.0_66/bin/java.exe" -Dhttp.proxyHost=http://webproxy.company.com -Dhttp.proxyPort=8080 -Dhttps.proxyHost=https://webproxy.company.com -Dhttps.proxyPort=8080 -Dhttps.proxyUser=zencv -Dhttp.proxyPassword=dadada -cp "C:\My programs\spring-1.3.5.RELEASE\bin\\..\lib\*" org.springframework.boot.loader.JarLauncher init
I am always getting the same error
Using service at https://start.spring.io
Failed to retrieve metadata from service at 'https://start.spring.io' (Connect to start.spring.io:443 [start.spring.io/141.101.112.192, start.spring.io/190.93.243.191] failed: Connection refused: conn
ect)
In-order to verify that I can reach the site from a command line using the above proxy, I used curl with proxy and was successful. Please help!

Related

ERROR io.opentelemetry.exporter.internal.grpc.OkHttpGrpcExporter

I am trying to connect my application to Signoz. It only works when both application and Signoz are running in the same machine. If I pull the application in another machine, I am getting timed out error.
ERROR io.opentelemetry.exporter.internal.grpc.OkHttpGrpcExporter - Failed to export spans. The request could not be executed. Full error message: connect timed out
My application is deployed in Wildfly so I have add the following JAVA_OPTS to the standalone.conf.bat
set "JAVA_OPTS=%JAVA_OPTS% -javaagent:c:/signoz/opentelemetry-javaagent.jar -Dotel.metrics.exporter=none -Dotel.exporter.otlp.endpoint=http://MyOtherServer:4318 -Dotel.resource.attributes=""service.name=MyService"""
opentelemetry-javaagent by default expects gRPC protocol that is usualy listening on port 4317.
If your collector listens on 4318, it is otlp-http. That means you must also set
-Dotel.exporter.otlp.protocol=http/protobuf
Source: https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md#otlp-exporter-span-metric-and-log-exporters

InfluxDBv2 - get a remote config working as a telegraf windows service

I'm trying to use the remote config feature of InfluxDB and Telegraf. If I set the enviroment variable with
$env:INFLUX_TOKEN = "thisIsMyToken"
and then test things with
.\telegraf.exe --config "https://influxdbserver:port/myremoteconfig" --test
it seems to be working.
When I try to install the service with
.\telegraf.exe --service install --config "https://influxdbserver:port/myremoteconfig"
the connection does not work and according to the windows event manager it can't load the config file due to "401 Unauthorized". Which is the same error I get when not setting the token before using the --test command.
I assume the problem is with the service not seeing the enviroment variable. But how can I get the variable into the service?
You can use setx, though that'll set an env var that all users on your system can view
setx /M INFLUX_TOKEN "ThisisMyToken"
credits to kittenless_tootler

"c8ycli server" returns an error when try to connect behind the proxy

I need to use cumulocity behind the proxy server. Therefore, I have set the proxy addresses using: "npm set proxy" and "npm set https-proxy". Now I am able to run a standard angular project and it works fine.
But when I create a c8y project and run it using "c8ycli server -u ...", I get this error by each request:
[HPM] Error occurred while trying to proxy request /tenant/loginOptions from localhost:9000 to https://....com (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)
Does c8ycli use npm proxy settings? How can I set proxy address for c8ycli?
I think it has nothing to do with c8y itself. You should try setting the proxy manually with npm:
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
Taken from here
Hope this help!
Edit:
Checking at the c8y tool (/usr/local/lib/node_modules/cumulocity-tools in my case) I notice they are using express (lib/devserver/server.js) when you run the server command. In that file they use their own proxy (lib/devserver/proxy.js) settings to resolve the localhost to the tenant's url.
As they are using express I think you can change those file to set you proxy configurations. I have not much experience with express but I found some information searching
express behind-proxies
nodejs-express-why-should-i-use-app-enabletrust-proxy
using-app-set-to-set-trust-proxy
Good luck!

Specifying an http proxy with spring-boot

How do I specify a http proxy to use when running a spring-boot fat war as a tomcat server?
I have tried the following which is not working.
java -jar my-application.war --http.proxyHost=localhost --http.proxyPort=3128 --https.proxyHost=localhost --https.proxyPort=3128
and
java -jar my-application.war -Dhttp.proxyHost=localhost -Dhttp.proxyPort=3128 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128
I've found that I need -Dhttps.proxySet=true in order for the proxy config to actually be used.
Put the JVM options before -jar. This should work:
java -Dhttp.proxyHost=localhost -Dhttp.proxyPort=3128 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128 -jar my-application.war
Explanation
According to java command-line documentation, the command's syntax is:
java [ options ] -jar file.jar [ arguments ]
The arguments are the args that'll be received in your main(String[] args). So, it's totally your responsibility to use them somehow. And if you forward them to spring using SpringApplication.run(MyApplication.class, args);, then you need to find documentation that says how spring uses args in the run method.
The options, however, are not sent to your app. One of their uses is to set what java calls system properties using -Dproperty=value. According to Java Networking and Proxies, setting, e.g., http.proxyHost property makes the JVM proxy all your http request through that host.
You may configure all property of REMOTE DEVTOOLS (RemoteDevToolsProperties) in application.properties.
spring.devtools.remote.context-path= # Context path used to handle the remote connection.
spring.devtools.remote.proxy.host= # The host of the proxy to use to connect to the remote application.
spring.devtools.remote.proxy.port= # The port of the proxy to use to connect to the remote application.
spring.devtools.remote.restart.enabled=true # Whether to enable remote restart.
spring.devtools.remote.secret= # A shared secret required to establish a connection (required to enable remote support).
spring.devtools.remote.secret-header-name=X-AUTH-TOKEN # HTTP header used to transfer the shared secret.
need to add for authenticating proxy server
-Dhttp.proxyUser=**username**
-Dhttp.proxyPassword=**password**

Making spring boot boostrap behind proxy

I tried to use Spring Boot using proxy.
I get the following message
$ spring init -l
Failed to retrieve help from service at 'https://start.spring.io'
(start.spring.io: unknown error)
I tried following
export http_proxy
export https_proxy
JAVA_OPTS settings
We are using commons HttpClient and we build a default instance via HttpClientBuilder
There are a bunch of system properties that are taken into account but I assume the following is the ones you're looking for:
http.proxyHost
http.proxyPort
Can you try that? If that does not work, please raise an issue on the boot tracker
Behind corporate proxy using locally installed cntlm proxy:
JAVA_OPTS
-Dhttp.proxyHost=localhost -Dhttp.proxyPort=3128 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128
Output:
$ spring init
Using service at https://start.spring.io
Content saved to 'demo.zip'
Use
-Dhttp.proxyHost=your.proxy.net -Dhttp.proxyPort=8080

Resources