'Java transformation :javax.net.ssl.SSLException:Connection timedout(Read failed)
I am trying to do a http post request using java transformation and developed the java code in java transformation. The workflow runs long and gives the response
javax.net.ssl.SSLException:Connection timedout (read failed).
The code works fine in the Java environment. Is there anything else I need to configure in informatica designer.
The following is the code Id and Email and access tokens are three input ports whereas line and final_response are output ports:
try{
URL url=new URL("https://ditabc.com");
System.setProperty("https.keepAlive","false");
System.setProperty("https.protocols","TLSv1,TLSv1.1,TLSv1.2");
HttpsURLConnection conn=(HttpsURLConnection)url.openConnection();
conn.setDoOutput(true);
conn.setRequestProperty("Authorization",access_token);
conn.setRequestMethod("POST");
conn.setRequestProperty("Accept","application/json");
conn.setRequestProperty("Content-Type","application/json");
String requestBody ="[{\"Id\":\"Id\", \"Email\":\"Email\"}]";
try(OutputStream os =conn.getOutputStream()){
byte[] input=requestBody.getBytes("utf-8");
os.write(input,0,input.length);
} catch(Exception e) {
System.out.println(e);
}
StringBuffer response= new StringBuffer();
BufferedReader reader =new BufferedReader(new InputStreamReader(conn.getInputStream()));
if (conn.getResponseCode() ==HttpsURLConnection.HTTP_OK){
while ((line=reader.readLine())!= null){
response.append(line);
}
final_response= response.toString();
}
reader.close();
conn.disconnect();
} catch(Exception e) {
logInfo("Error");
final_response =e.toString();
am I missing out any other configuration in order to do a post request using Java transformation?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
