Custom C# Function Client Timeout / Server side keeps running

Hi, we have a custom c# function that handles a Bill Of Material as incoming JSON DataSet.

The function then updates / Inserts records for all the parts in the BOM and then does the same for the BOM structure with the PartMTL.

the default timeout for function calls seems to be set at 4 minutes, we had Epicor increased the server-side timeout from 4min to o / not set which they said will make it timeout after 30min due to SQL DB timeout settings.

The behavior I am seeing is that our Application makes a call EpicorRest.EfxPostAsync(…)
and we still get a timeout after 4minutes but even though the client threw this error, the server side still runs. If there were no issues we see the results eventually by trying to call the relevant data again to see if it updated but if there was an issue we don’t know what it was since we weren’t connected to receive the reply anymore.

I have updated the EpicorRest.Timeout to be something much higher than 4min to make sure that is not what we are hitting (900 * 1000)ms

Error Message: GatewayTimeout
Unexpected character encountered while parsing value: <. Path ā€˜ā€™, line 0, position 0.

<head>
    <meta content='text/html; charset=utf-8' http-equiv='content-type' />
    <style type='text/css'>
        body {
            font-family: Arial;
            margin-left: 40px;
        }

        img {
            border: 0 none;
        }

        #content {
            margin-left: auto;
            margin-right: auto
        }

        #message h2 {
            font-size: 20px;
            font-weight: normal;
            color: #000000;
            margin: 34px 0px 0px 0px
        }

        #message p {
            font-size: 13px;
            color: #000000;
            margin: 7px 0px 0px0px
        }

        #errorref {
            font-size: 11px;
            color: #737373;
            margin-top: 41px
        }
    </style>
    <title>Service unavailable</title>
</head>

<body>
    <div id='content'>
        <div id='message'>
            <h2>Our services aren't available right now</h2>
            <p>We're working to restore all services as soon as possible. Please check back soon.</p>
        </div>
        <div id='errorref'>
            <span>20241204T222837Z-15fdbff69c5knmsnhC1CH18zpg0000000gwg00000000w16t            </span>
        </div>
    </div>
</body>
</html>

An easy workaround is to have another function schedule the actual function to run immediately, and then return.

I have one on here somewhere, let me find it.

1 Like
1 Like

If I call this to schedule the Function that takes a longer time to run. Is there a way I can wait for the response back? as that returns useful information to the user.

Side question: are you using the business objects or making direct SQL updates in this function?

1 Like

No.

And if you are making users wait for longer than a few seconds now, that’s probably not good design.

The best alternative for that is probably to have some sort of status check. Write status in your function, and have a way to check it.

1 Like

I need to re-do my bartender integration for this reason, the response takes too long when the job is large…

1 Like

As Kevin says, we really don’t want to lock up the UI for that. There are lots of articles about handling ā€œlong runningā€ API tasks. Here’s one:

2 Likes

we use services like: PartSvcContract, PartXRefMfgSvcContract, EngWorkBenchSvcContract (for Bom Structure)
but then update the relevant columns manually and set the record RowMod to ā€œUā€

2 Likes

the current workflow is a user saves the most up to date version of the BOM and then will go on to the next step to get parts ordered as soon as the updated part info is available. So alerting the user to the status as soon as possible is ideal.
This function being large (~2000 lines with whitespace) there are a lot of statuses that could require the user to try again after fixing some relevant part of their BOM data, and reporting these messages back is also a priority.

How are you recording the various statuses?

The hard thing is, the user is sitting there wondering why the print job didn’t print, but I don’t know that till it’s done and writes the error message so they’ll be waiting there regardless, but the ā€œlocking up the UIā€ is ugly and causes people to get angry so I need to stop that ASAP.

Trying to re-write my integration to send XML of all relevant fields to make it even speedier.

for this we are calling this with an ASync call so the UI isn’t locked up, but has a wait screen going, which shows the overall status of what function is being called so they get some progress with that.

there are two statuses that we use, one happens right away if we notice something incorrect on the incoming validation of the dataset and we return a dataset in return with a status message for each offending part.

otherwise we just have an overall status message that marks where in the function / section of code we are running with what specifics are relevant, that way if an error is thrown we know what the last step we were working on was.

1 Like

I thought I was also calling async, but I do have it waiting to do something with the response so that’s probably what’s hanging it up.

Suggestion

When the user submits their stuff and the function gets scheduled (asynchronously) update ā€œStatusā€ of Record to ā€œProcessing Updateā€

Then at the end of the function go back and Mark it as ā€œDoneā€

And use Email for notification (or Collaborate if you are fancy)

If its taking 4+ minutes to run the update I think an asynchrony notification is pertinent. Nobody wants to sit on a scren for 4 minutes

2 Likes

The worst part about the customization I made was I tested it on all small jobs… and then one machine operator was like, I sit here and run one job for 8 hours making hundreds of parts needing labels… Well, when you submit a job for 400-500 labels vs one for 20 labels that’s when you get the 4 minutes of spinning death.

It’s been on my to-do list for a minute now :man_facepalming:

2 Likes