cancel
Showing results for 
Search instead for 
Did you mean: 

HttpException: Connect timed out in UDF

smitha_gatty
Explorer
0 Kudos

Hi All,

We have scenario where we make a HTTP call to generate salesforce token via UDF using OAuth authentication, it works fine in SAP PI 7.5 dev environment

When we are trying to do the same in test environment we are seeing 'org.w3c.www.protocol.http.HttpException: Connect timed out'

The UDF code and the parameters used and token URL(via VM) all remains the same in both environments.

The UDF code goes as below

String urlParameters = "grant_type=password&username="+username+"&password="+password+"&client_id="+client_id+"&client_secret="+client_secret;

byte[] postData = urlParameters.getBytes(StandardCharsets.UTF_8);

URL url = new URL( token_url);

HttpURLConnection httpClient = (HttpURLConnection) url.openConnection();

httpClient.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded");

DataOutputStream wr = new DataOutputStream(httpClient.getOutputStream());

wr.write(postData);

The configuration works well if used in SAP REST communication channel in test environment as well

Any suggestions on what could be causing this issue in ESR (UDF) of test environment only, any help appreciated.

Regards,

Smitha

Accepted Solutions (0)

Answers (1)

Answers (1)

PriyankaChak
Active Contributor
0 Kudos

Hi Smitha,

You can try to increase timeout and see if it works.

Regards,

Priyanka

smitha_gatty
Explorer
0 Kudos

hi Priyanka,

I did try adding httpClient.setConnectTimeout(60000); but the issue still remains.

Regards,

Smitha