Occasional Thread Aborted during REST call

Occasional Thread Aborted during REST call

  

Hello,

I'm getting an occasional thread aborted error while calling a REST service from within a loop (once or twice out of ~2,000 calls).

Service Center shows the following error, but I don't know what the underlying issue might be:

Thread was being aborted.
   at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
   at System.Net.ConnectStream.ProcessWriteCallDone(ConnectionReturnResult returnResult)
   at System.Net.ConnectStream.CallDone(ConnectionReturnResult returnResult)
   at System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean aborting)
   at System.Net.ConnectStream.System.Net.ICloseEx.CloseEx(CloseExState closeState)
   at System.Net.HttpWebRequest.EndWriteHeaders_Part2()
   at System.Net.HttpWebRequest.EndWriteHeaders(Boolean async)
   at System.Net.HttpWebRequest.WriteHeadersCallback(WebExceptionStatus errorStatus, ConnectStream stream, Boolean async)
   at System.Net.ConnectStream.WriteHeaders(Boolean async)
   at System.Net.HttpWebRequest.EndSubmitRequest()
   at System.Net.Connection.SubmitRequest(HttpWebRequest request, Boolean forcedsubmit)
   at System.Net.ServicePoint.SubmitRequest(HttpWebRequest request, String connName)
   at System.Net.HttpWebRequest.SubmitRequest(ServicePoint servicePoint)
   at System.Net.HttpWebRequest.GetResponse()
   at ssGuestAccountsData.CcIdmOutSystemXXXX.ActionIntGetXXXXUser(HeContext heContext, ICcIdmOutSystemXXXXCallbacks _callbacks, String inParamSearchUser, String inParamInvokingUser, String inParamService, STIntGetXXXXUserResponseStructure& outParamResponse)


Also, is there any way within OutSystems to allow the process to continue if the REST call generates this error?

Thanks,
-Ryan


Solution

Hi Ryan,

The likely cause of such an error is either a timeout or some hickup in the network or infrastructure (either locally or on the server the REST service runs on). The result is an Exception in OutSystems. To catch an Exception, use the Excepion Handler statement:

If you want to keep processing your loop, wrap the REST call inside an Action with an Exception Handler, and let it pass some error code or the like to your main Action (containing the loop), and test for that error code inside the loop.

Solution

Kilian Hekhuis wrote:

Hi Ryan,

The likely cause of such an error is either a timeout or some hickup in the network or infrastructure (either locally or on the server the REST service runs on). The result is an Exception in OutSystems. To catch an Exception, use the Excepion Handler statement:

If you want to keep processing your loop, wrap the REST call inside an Action with an Exception Handler, and let it pass some error code or the like to your main Action (containing the loop), and test for that error code inside the loop.


Thanks Kilian!

You're welcome :)