java.security.PrivilegedActionException: java.net.SocketTimeoutException: Read timed out

1
Hi,   Has anyone encountered this error?   Our call to the REST API has been intermittent. We’ve shorted the timeout just to allow the user to click the button again and make the REST call which most of the time will push thru after the error. But this is not a good user experience.   Please advise.   Regards, Rom   Below is a sample stack trace   2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT ERROR - CRS_BAPIAccountingPOST: REST error occurred when posting RFP to SAP. 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT LATEST ERROR 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT ------------ 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT Error Type 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT java.net.SocketTimeoutException 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT Error Message 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT Read timed out 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT Error Stacktrace 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT Error calling REST service 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT at API.CRS_BAPIAccountingPOST (CallRest : 'Call REST (POST)') 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT at SimpliRFP.ACT_ForPosting (SubMicroflow : 'CRS_BAPIAccountingPOST') 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT Advanced stacktrace: 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT at com.mendix.integration.actions.microflow.RestCallAction.execute(RestCallAction.scala:79) 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT Caused by: 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT java.security.PrivilegedActionException: java.net.SocketTimeoutException: Read timed out 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT at com.mendix.integration.actions.microflow.RestCallAction.execute(RestCallAction.scala:79) 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT Caused by: 2023-02-06T07:05:37.349Z [APP/PROC/WEB] OUT null 2023-02-06T07:05:37.350Z [APP/PROC/WEB] OUT at com.mendix.integration.actions.microflow.RestCallAction.execute(RestCallAction.scala:79) 2023-02-06T07:05:37.350Z [APP/PROC/WEB] OUT Caused by: 2023-02-06T07:05:37.350Z [APP/PROC/WEB] OUT Read timed out 2023-02-06T07:05:37.350Z [APP/PROC/WEB] OUT at com.mendix.integration.actions.microflow.RestCallAction.execute(RestCallAction.scala:79) 2023-02-06T07:05:37.350Z [APP/PROC/WEB] OUT LATEST HTTPRESPONSE 2023-02-06T07:05:37.350Z [APP/PROC/WEB] OUT ------------------- 2023-02-06T07:05:37.350Z [APP/PROC/WEB] OUT null 2023-02-06T07:05:37.350Z [APP/PROC/WEB] OUT Content 2023-02-06T07:05:37.350Z [APP/PROC/WEB] OUT null 2023-02-06T07:05:37.350Z [APP/PROC/WEB] OUT HttpVersion 2023-02-06T07:05:37.350Z [APP/PROC/WEB] OUT null 2023-02-06T07:05:37.350Z [APP/PROC/WEB] OUT REQUEST BODY 2023-02-06T07:05:37.350Z [APP/PROC/WEB] OUT ------------ 2023-02-06T07:05:37.351Z [APP/PROC/WEB] OUT {"companyCode":"2000","documentType":"KR","documentDate":"2023-01-02","postingDate":"2023-02-06","documentHeaderText":"PRO202311692\nBCFG","accountGl":[{"itemNo":"2","itemText":"AP-SPP#PRO202311692; approved by MVCrucillo","currency":"PHP","accountCode":"0013000002","taxCode":"I2","profitCenter":"PHM2600000","costCenter":"","wbsElement":"","internalOrder":"","glAmount":1666.16},{"itemNo":"3","itemText":"AP-SPP#PRO202311692; approved by MVCrucillo","currency":"PHP","accountCode":"0013000002","taxCode":"IX","profitCenter":"PHM2600000","costCenter":"","wbsElement":"","internalOrder":"","glAmount":188.92}],"accountPayable":[{"itemNo":"1","text":"AP Line Item","currency":"PHP","grossAmt":-1855.08,"amountInDocumentCurr":0,"vendorCode":"0020001690","paymentTerms":"*","paymentMethod":"Y","baselineDate":"2023-02-01","allocationNo":"RFP2000-0020001690-11","paymentBlock":""}],"nonBapiDetails":{"process":"","transaction":"","typeOfInvestment":"","typeOfSettlement":"","placementDate":"","grossInterestRate":"","netInterestRate":""},"reference":"00124228","username":"RBP151","grossAmt":-1855.08,"currency":"PHP","accountWhtax":[{"itemNo":"1","withholdingTaxType":"EI","withholdingTaxCode":"23","amountWithheldTc":29.75,"baseAmountTc":1487.64}],"taxCode":"**","grCategory":""} 2023-02-06T07:05:37.351Z [APP/PROC/WEB] OUT ERROR - CRS_BAPIAccountingPOST: com.mendix.modules.microflowengine.MicroflowException: Error calling REST service 2023-02-06T07:05:37.351Z [APP/PROC/WEB] OUT at API.CRS_BAPIAccountingPOST (CallRest : 'Call REST (POST)') 2023-02-06T07:05:37.351Z [APP/PROC/WEB] OUT at SimpliRFP.ACT_ForPosting (SubMicroflow : 'CRS_BAPIAccountingPOST') 2023-02-06T07:05:37.351Z [APP/PROC/WEB] OUT Advanced stacktrace: 2023-02-06T07:05:37.351Z [APP/PROC/WEB] OUT at com.mendix.integration.actions.microflow.RestCallAction.execute(RestCallAction.scala:79) 2023-02-06T07:05:37.351Z [APP/PROC/WEB] OUT Caused by: com.mendix.systemwideinterfaces.MendixRuntimeException: java.security.PrivilegedActionException: java.net.SocketTimeoutException: Read timed out 2023-02-06T07:05:37.352Z [APP/PROC/WEB] OUT at com.mendix.integration.util.PrivilegedUtil$$anonfun$withPrivileged$2.applyOrElse(PrivilegedUtil.scala:17) 2023-02-06T07:05:37.352Z [APP/PROC/WEB] OUT Caused by: java.security.PrivilegedActionException: null 2023-02-06T07:05:37.352Z [APP/PROC/WEB] OUT at java.base/java.security.AccessController.doPrivileged(Native Method) 2023-02-06T07:05:37.352Z [APP/PROC/WEB] OUT at com.mendix.integration.util.PrivilegedUtil$.$anonfun$withPrivileged$1(PrivilegedUtil.scala:13) 2023-02-06T07:05:37.352Z [APP/PROC/WEB] OUT at scala.util.Try$.apply(Try.scala:210) 2023-02-06T07:05:37.352Z [APP/PROC/WEB] OUT at com.mendix.integration.util.PrivilegedUtil$.withPrivileged(PrivilegedUtil.scala:13) 2023-02-06T07:05:37.352Z [APP/PROC/WEB] OUT at com.mendix.http.LoggableHttpClient.execute(LoggableHttpClient.scala:26) 2023-02-06T07:05:37.352Z [APP/PROC/WEB] OUT at com.mendix.http.HttpExecutor$.$anonfun$request$1(HttpExecutor.scala:15) 2023-02-06T07:05:37.352Z [APP/PROC/WEB] OUT at scala.util.Try$.apply(Try.scala:210) 2023-02-06T07:05:37.352Z [APP/PROC/WEB] OUT at com.mendix.http.HttpExecutor$.request(HttpExecutor.scala:15) 2023-02-06T07:05:37.352Z [APP/PROC/WEB] OUT at com.mendix.integration.actions.microflow.RestCallAction.execute(RestCallAction.scala:73) 2023-02-06T07:05:37.352Z [APP/PROC/WEB] OUT at com.mendix.integration.actions.microflow.RestCallAction.execute(RestCallAction.scala:39) 2023-02-06T07:05:37.352Z [APP/PROC/WEB] OUT at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.$anonfun$execute$1(MicroflowObject.scala:32) 2023-02-06T07:05:37.352Z [APP/PROC/WEB] OUT at scala.Option.flatMap(Option.scala:283) 2023-02-06T07:05:37.353Z [APP/PROC/WEB] OUT at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.scala:29) 2023-02-06T07:05:37.353Z [APP/PROC/WEB] OUT at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.$anonfun$executeAfterBreakingIfNecessary$2(MicroflowImpl.scala:167) 2023-02-06T07:05:37.353Z [APP/PROC/WEB] OUT at scala.Option.flatMap(Option.scala:283) 2023-02-06T07:05:37.353Z [APP/PROC/WEB] OUT at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.scala:167) 2023-02-06T07:05:37.353Z [APP/PROC/WEB] OUT at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.scala:114) 2023-02-06T07:05:37.353Z [APP/PROC/WEB] OUT at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:58) 2023-02-06T07:05:37.353Z [APP/PROC/WEB] OUT at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.doCall(CoreActionHandlerImpl.scala:71) 2023-02-06T07:05:37.353Z [APP/PROC/WEB] OUT at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.call(CoreActionHandlerImpl.scala:48) 2023-02-06T07:05:37.353Z [APP/PROC/WEB] OUT at com.mendix.core.actionmanagement.internal.InternalCoreAction.call(InternalCoreAction.java:56) 2023-02-06T07:05:37.353Z [APP/PROC/WEB] OUT at com.mendix.basis.actionmanagement.ActionManager.$anonfun$executeSync$2(ActionManager.scala:104) 2023-02-06T07:05:37.353Z [APP/PROC/WEB] OUT at com.mendix.util.classloading.Runner$.withContextClassLoader(Runner.scala:20) 2023-02-06T07:05:37.354Z [APP/PROC/WEB] OUT at com.mendix.basis.actionmanagement.ActionManager.executeSync(ActionManager.scala:103) 2023-02-06T07:05:37.354Z [APP/PROC/WEB] OUT at com.mendix.basis.component.ExecutionCore.doExecuteSync(ExecutionCore.scala:148) 2023-02-06T07:05:37.354Z [APP/PROC/WEB] OUT at com.mendix.basis.component.ExecutionCore.doExecuteSync$(ExecutionCore.scala:147) 2023-02-06T07:05:37.354Z [APP/PROC/WEB] OUT at com.mendix.basis.component.InternalCore.doExecuteSync(InternalCore.scala:24) 2023-02-06T07:05:37.354Z [APP/PROC/WEB] OUT at com.mendix.basis.component.ExecutionCore.executeSync(ExecutionCore.scala:97)  
asked
1 answers
0

Hi Romuel,

 

Try the following solutions detailed in the Mendix documentation about java.net.SocketException – Connection reset:

 

"This error occurs when your app’s infrastructure closes the connection because it is inactive. Your app client does not know this and gets this error when it makes a new request.

There are two ways to resolve this:

  1. Alter the value of the http.client.CleanupAfterSeconds runtime setting to be less than the connection timeout. This will ensure that the your app client will create a new HTTP client for the request.

  2. Handle the error in your microflow and retry a number of times before returning the error. Your flow might look similar to the one below."

 

You may want to implement something similar detailed in the documentation. But instead of Socket Exception you may want to change that into the error you are getting:

image.png

 

Hopefully this way you can implement a retry functionality as a workaround.

 

I hope this information is able to help you solve your problem, best regards!

answered