My Spring boot app is able to make calls to Google pub sub APIs and works perfectly as expected but only when it is not behind a proxy.
I am looking to deploy my app in on-premises datacenter which requires proxy to make outbound HTTP call.
I used HTTPS_PROXY in my environment.. its not working
I used grpc_proxy in my environment.. its not working
Getting this exception
Caused by: java.net.UnknownHostException: pubsub.googleapis.com
at java.base/java.net.InetAddress$CachedAddresses.get(InetAddress.java:797)
at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1505)
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1364)
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1298)
at io.grpc.internal.DnsNameResolver$JdkAddressResolver.resolveAddress(DnsNameResolver.java:631)
at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:219)
is there any other way to have proxy injected for google libraries ?
Got a solution for this. As mentioned here, we would have to use GRPC_PROXY_EXP.
I gave it this way GRPC_PROXY_EXP=internet.company.com:93 and it worked perfectly fine
grpc-java and many Java HTTP libraries use the Java-standard -Dhttps.proxyHost=HOST/-Dhttps.proxyPort=PORT for configuring use of a proxy server.
You can't configure them with an environment variable. It is common to just pass the -Ds on the command line. If you want to configure this globally you can change lib/net.properties in the JRE.
Related
I am running into the follow error while upgrading my versions of Jetty for a Dropwizard project:
java.lang.IllegalStateException: KeyStores with multiple certificates are not supported on the base class org.eclipse.jetty.util.ssl.SslContextFactory. (Use org.eclipse.jetty.util.ssl.SslContextFactory$Server or org.eclipse.jetty.util.ssl.SslContextFactory$Client instead)
The tricky part is that I do not directly set up my SslContextFactory in code. Instead, Dropwizard sets it up behind the scenes at application startup, where it quickly runs into this issue and fails.
I see from the Dropwizard documentation that certain environment variables can be set on the Jetty server that it spins up, but I do not see documentation on how to modify specific classes.
If I add a jetty.xml file within $JETTY_HOME$/etc/config, will Dropwizard know how to pick this up?
I just need to understand how Dropwizard picks up settings on Jetty so I can use SslContextFactory.Server and resolve this error at startup.
Your version of Dropwizard is too old.
Dropwizard properly uses the SslContextFactory.Server where appropriate.
I have a big problem, I want to send my backend to Google Cloud Run however, I get the following error when I follow this tutorial for the jvm part: https://quarkus.io/guides/deploying-to-google-cloud#deploying-to-google-cloud-run
ERROR: (gcloud.run.deploy) The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information.
I tried to defined this variable in my application.yml : quarkus.http.port: 8080 but it still doesn't work :(
If you have any advice, I am interested, thank you very much
Look at https://github.com/cescoffier/polycloud-demo/blob/main/src/main/resources/application.properties.
This is part of a demo deploying on Google Cloud Run. As you can see, the port is configured using:
quarkus.http.port=${PORT:8080}
Also, make sure your application starts correctly. If there is an issue during the startup, the port is not opened.
I am using spring.data.elasticsearch with Elasticsearch 7.14.1 in my Spring Boot (2.5.4) application.
My application.properties is something like this
spring.elasticsearch.rest.uris=elasticsearch:9200
spring.data.elasticsearch.cluster=elasticsearch:9200
spring.data.elasticsearch.repositories.enabled=true
This works fine as long as the invocation is from localhost, no issues. However, when I try to bring up my Spring Boot container, I see a failure with NoReachableHostException
reactor.core.Exceptions$ErrorCallbackNotImplemented: org.springframework.data.elasticsearch.client.NoReachableHostException: Host 'localhost:9200' not reachable. Cluster state is offline.
blah-blah-service
Caused by: org.springframework.data.elasticsearch.client.NoReachableHostException: Host **'localhost:9200'** not reachable. Cluster state is offline.
blah-blah-service
at org.springframework.data.elasticsearch.client.reactive.SingleNodeHostProvider.lambda$lookupActiveHost$3(SingleNodeHostProvider.java:101)
Clearly, my suggestion to use "elasticsearch" host (defined network, that is tested and accessible from within and outside docker containers), hasn't gone well with Spring Data for whatever reason. I have even used
#PropertySource("classpath:mysearch.properties")
in my application to try and coax these properties into the app, but doesn't look like anything works. Is there something I am missing in my Elasticsearch configuration or otherwise?
PS: I have exercised curl http://elasticsearch:9200 from within the container and find no issues
These configurations are Spring Boot specific, Spring Data Elasticsearch does not use them. But as far as I can see, you are configuring the transport client (cluster entry, should not be used anyway) and the imperative REST client, but according to the error message you are using the reactive REST client.
According to the Spring Boot documentation you would need to set spring.data.elasticsearch.client.reactive.endpoints
In the .properties file, I used the below and solved the issue for me;
spring.elasticsearch.rest.uris=http://localhost:<port_number>
spring.data.elasticsearch.client.reactive.endpoints=localhost:<port_number>
I have an application that uses spring to the calling rest services. Specifically, the RestTemplate class. Right before I make the call to:
restTemplate.execute(
url,
method,
new JSONRequestCallback(headerParams),
new JSONResponseExtractor(containerType, cls));
method, I check the value url in the call. I quite literally can copy and paste the value of that url (lets call it http://myHost.net:8081) into a browser in the same network domain as my tomcat 8 (the web container I am using in eclipse), and the service response is successfully returned from the browser. However, the execute method throws an exception upon return:
org.springframework.web.client.ResourceAccessException: I/O error: myHost.net; nested exception is java.net.UnknownHostException: myHost.net
Now, the web service I am calling is on the internet while my dev environment is not. To address, we opened an appropriate port in our firewall and I can successfully access the service endpoint from a browser (as indicated above) by properly configuring the proxy settings on the browser. Similarly, from my Tomcat 8 configuration within eclipse, I have added the following launch configuration VM arguments:
-Dhttp.proxySet=true
-Dhttp.proxyHost=myHost.net
-Dhttp.proxyPort=8080
but as I have indicated above, I still get the unknown host exception.
By the way, I did see a similar issue here (Spring RestTemplate and Proxy Auth) but that required a coding solution in the spring code. I was hoping for a configuration solution as our system will not have the proxy issue in the operational environement.
I am hoping someone might have some ideas as to either what I might be doing wrong, and/or how I might be able to better diagnose my problem. Thank you!
I am trying for several hours to get the HornetQ Examples running in Eclipse. Using the Standalone Examples everything works fine, but when I run the examples in Eclipse I get the following error:
javax.jms.JMSSecurityException: Unable to validate user: null
What could this error mean? Where do I have to specify the user? Maybe HornetQ tries to look this user up in "Some Context/Properties" etc , but I do not know where and how to specifiy the user HornetQ is running under.
What i did:
1.)Started Default HornetQ Server with the start.sh Script in the ./bin directory
2.)Copied the QueueExample over to eclpise
3.)Did some minor changes in the config files (to have the same Queue Names...)
(I also tried to disable security completely by setting:
<security-enabled>false</security-enabled>
but with no success, always getting the same error. Also when trying to programmatically instance HornetQ only via classes I get this error too).
Thank you very much!!
Jens
Did you have a look at this thread? It seems you need to the permission 'createTempQueue' to the example role.