We have a private space and gave access to one of the internal API so that we could access it from the private space app. So, we've developed a demo Java app to test it. When we try to connect the service with an HTTP Get the stack trace ends like this.
java.net.UnknownHostException: [THE_VALID_URL] Name or service not known
java.base/java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:929)
at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1519)
at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:848)
at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1509)
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1368)
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1302)
at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
When we ping the corresponding IP within the private space we can see that it's up. But when we try to access the service from the Java application it ends up like above.
The Java code is like this:
RequestConfig config = RequestConfig.DEFAULT;
HttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
HttpGet httpGet = new HttpGet("[THE_VALID_URL]");
httpGet.addHeader("Content-Type", "application/json; UTF-8");
HttpResponse resp = client.execute(httpGet);
Does anyone have any ideas to solve this?
Thank you.
[UPDATE]: Solved with this https://stackoverflow.com/a/35327982/7595094