I have two app ("A" and "B") and i want to bind these with an Azure function. "A" throw my Azure function (module tiers) and then, i want (from module tiers) send a request Http to "B" to retrieve data but it doesn't work.
To be sure all port or another stuff is open, i created a VM on same subnet as "B" and module tiers and this test VM can retrieve data after put my basic auth login/password via chrome navigator.
Here, i'm sure it is possible to reach my data but...
The Azure function create in Java cannot reach my precious data...
1st initiative : I tried to use Curl into my code with basic auth and when i want to do an "getInputStream()" there is trouble. The log said :
2021-08-17T07:09:03.405 [Error] Executed 'Functions.pagination' (Failed, Id=93357ae7-9dc3-453a-97e7-332cc653d187, Duration=1500ms)
Result: FailureException: IOException: CreateProcess error=2, The system cannot find the file specifiedStack: java.lang.reflect.InvocationTargetExceptionat
with this code :
File file = File.createTempFile("test", "txt");
Process process = Runtime.getRuntime().exec("curl --cookie \"Authorization=Basic " + encoding + "\" " + urlDenodo,
null ,
file);
2nd initiative : I tried to use HttpClient with Basic auth in header but i have an access denied The log said :
2021-08-17T08:57:05.059 [Error] Executed 'Functions.pagination' (Failed, Id=dd9480ec-f49b-4ddc-8d81-8f1dc6ab5e44, Duration=1032ms)
Result: FailureException: SocketException: Permission denied: connectStack: java.lang.reflect.InvocationTargetExceptionat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
with this code :
URL url = new URL (urlDenodo);
String encoding = Base64.getEncoder().encodeToString(("admin:admin").getBytes("UTF-8"));
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setConnectTimeout(100000);
//connection.setDoOutput(true);
connection.setRequestProperty ("Authorization", "Basic " + encoding);
InputStream content = (InputStream)connection.getInputStream();
BufferedReader in =
new BufferedReader (new InputStreamReader (content));
String line;
But now, i don't know what to do in order to call "B" via a simple URL
Thanks to help me !