简体   繁体   English

java.net.UnknownHostException:googleapis

[英]java.net.UnknownHostException: googleapis

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.我的 Spring 启动应用程序能够调用 Google pub sub API 并按预期完美运行,但前提是它不在代理后面。

I am looking to deploy my app in on-premises datacenter which requires proxy to make outbound HTTP call.我希望在本地数据中心部署我的应用程序,该数据中心需要代理才能进行出站 HTTP 呼叫。

  1. I used HTTPS_PROXY in my environment.. its not working我在我的环境中使用HTTPS_PROXY .. 它不起作用
  2. I used grpc_proxy in my environment.. its not working我在我的环境中使用grpc_proxy .. 它不起作用

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 .正如这里提到的,我们必须使用GRPC_PROXY_EXP

I gave it this way GRPC_PROXY_EXP=internet.company.com:93 and it worked perfectly fine我这样给它GRPC_PROXY_EXP=internet.company.com:93并且它工作得很好

grpc-java and many Java HTTP libraries use the Java-standard -Dhttps.proxyHost=HOST / -Dhttps.proxyPort=PORT for configuring use of a proxy server. grpc-java 和许多 Java HTTP 库使用Java 标准-Dhttps.proxyHost=HOST / -Dhttps.proxyPort=PORT来配置代理服务器的使用。

You can't configure them with an environment variable.您不能使用环境变量配置它们。 It is common to just pass the -D s on the command line.通常只在命令行上传递-D If you want to configure this globally you can change lib/net.properties in the JRE.如果要全局配置,可以更改 JRE 中的lib/net.properties

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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