web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Interactive session timeout

(2) ShareShare
ReportReport
Posted on by 162
Hi,

We have code that creates a delimited text file then download it
TextStreamIo    textStreamIo;


textStreamIo= TextStreamIo::constructForWrite();
textStreamIo.outFieldDelimiter('|');

//logic

File::SendFileToUser(stream, filename);


 
if data is big, we get this error: A time out error occured in the database while the query was executing

is it related to this october release?
Platform updates for version 10.0.46 of finance and operations apps (October 2025) - Finance & Operations | Dynamics 365 | Microsoft Learn


and how to fix?
Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    238,858 Most Valuable Professional on at
    If I understand correctly, you have a problem with a slow query, i.e. with some other code that what you showed above, and the title is wrong (it's not any file error). If so, please fix the title and give us some information about the actual problem.
     
    You mentioned an article about the 30-minutes query timeout. but you seem to be running the code in an interactive session and the session time out sooner than the query, does it?
  • CU22120935-0 Profile Picture
    162 on at
    Hi @Martin DrábMartin,

    yes it's a service class (sysOperationFramework) and in controller we hide the batch tab, so batch processing is false by default. Which means it's interactive session and the article said that axOnlineInteractive sessions was reduced from 30 minutes to 5 minutes.

    there is lots of code but there is one that takes much time and depends on ranges we put that might make it run lots of data
     
     
  • Martin Dráb Profile Picture
    238,858 Most Valuable Professional on at
    It's not true that if it doesn't run in batch, it must be executed synchronously. There are four execution modes and ScheduledBatch is just on of them. If you want to run your code synchronously, you must explicitly set  the execution mode accordingly (either using the constructor parameter of your controller or using parmExecutionMode()). The default execution mode of SysOperationServiceController is Asynchronous. I'm not sure how it's determined whether the session is interactive for the purpose of the query timeout; may guess is that Asynchronous is considered interactive unless you implement real async. But I expect File::SendFileToUser() fail in all cases except of synchronous processing (afterOperation() would help you when using async modes).
     
    Now please describe what happens when you execute your code (what times out, how long does it take, whether you get an exception etc.), which should answer your question whether it's related to the query timeout.
     
    Then explain what you want from us. Do you need a help redesigning your solution to run in background, without blocking the user and without issues with interactive sessions timeouts? Or do you insist on your architecture and you want to learn how to optimize SQL queries? Or something else?
     
  • CU22120935-0 Profile Picture
    162 on at
    Hi @Martin Dráb,

    it's synchronus, sorry for the confusion
    controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
    controller.showBatchTab(false);
    and the default one is syncrhonus as well


    So it's an interactive session. And I mentioned that i get this error after waiting more than 5 minutes:  A time out error occured in the database while the query was executing

    And what i need is how to fix it? can the waiting be extended and still keep using sendFileToUser? if not, can the query be enhanced (if you can see a real issue)? i think no or even if yes, it depends on dates, so it will get larger at the end?


    if the answer is no to all? what to do then? do we need to change the solution and convert it to report instead of file? or what to do in this case? what's the best solution
  • Martin Dráb Profile Picture
    238,858 Most Valuable Professional on at
    That Synchronous is the first element of the enum doesn't mean that it's the default value; a different one is used in the constructor of SysOperationServiceController. But okay, you've changed that to Synchronous.
     
    In my opinion, blocking a user session for more than five minutes is a bad design, therefore an attempt to extend the timeout and block the session for even longer time doesn't sound wise to me, even if it was possible (which doesn't seem to be the case). I suggest you generate the file in the background, notify the user when it's done and let the him/her to download it.
     
    Maybe the query can be improved, but I don't have any details. If you wish the follow this path, please create a new thread and provide necessary information (the purpose of the query, the number of records returned, query execution time, the execution plan...) there.
     
    Whether you want a report or not depends on your business requirements, which are unknown to me. But it's obviously important to decide such things before starting an implementation.
  • CU22120935-0 Profile Picture
    162 on at
    Hi Martin, @Martin Dráb
     
    When you say
    Genarate the file in the background
    Notify the user when it's done
    The user can download it
     
    Can you please explain further each point, what to do exactly in code. So File::sendFileToUser won't be used. What will be used and changed instead?
  • Martin Dráb Profile Picture
    238,858 Most Valuable Professional on at
    What code you need to write depends on what logic to decide to implement. You need to design the solution (and make some decisions) before you can write code.
     
    Let me mention just some of the options.
     
    One thing is clear - you'll need to run your slow queries, and most likely the file creation as well, in an asynchronous process. It may be a batch or another asynchronous execution mode. You'll need to store the file somewhere - the easiest way will be calling File::sendFileToTempStore().
     
    Then either persist the URL in database, or send it to a user (e.g. by email). In theory, you could utilize afterOperation() method of the controller to notify user directly after an asynchronous processing completes, but you can't know whether the user session will still be active and the information could get lost.
  • Martin Dráb Profile Picture
    238,858 Most Valuable Professional on at
    Thread title changed from file error to Interactive session timeout.
  • CU22120935-0 Profile Picture
    162 on at
    Hi @Martin Dráb

    So you mean to make this whole code run in batch instead of synchronus and use File::sendFileToTempStore() instead of sendFileToUser().
    This 
    File::sendFileToTempStore() will generate a temp URL right? where shall i save it in the DB?

    and if instead of saving it in DB, if i will send an email, then this needs custom x++ code inside the same service class?

    You also said "afterOperation() method of the controller to notify user directly after an asynchronous processing completes but you can't know whether the user session will still be active and the information could get lost."
    you mean if the user refreshes the page, it will be lost?
    and how to notify the user? i don't think you mean email because if u mean email, what will be the difference if i send the email inside the service class or in afterOperation method in controller?
  • Martin Dráb Profile Picture
    238,858 Most Valuable Professional on at
     
    Question: So you mean to make this whole code run in batch instead of synchronus?
    Answer: I suggested running asynchronously, a batch is just one of the options. For simplicity, we can talk about a batch only.
     
    Question: This File::sendFileToTempStore() will generate a temp URL right?
    Answer: Yes, it returns a URL of the file in the temporary storage.
     
    Question: where shall i save it in the DB?
    Answer: Where you want; I don't know your business scenario. You can see an example in the standard solution for data export, i.e. data management. 
     
    Question: You also said "afterOperation() method of the controller to notify user directly after an asynchronous processing completes but you can't know whether the user session will still be active and the information could get lost."
    you mean if the user refreshes the page, it will be lost?
    Answer: No, if the user session isn't active anymore (the user closed the browser, the session expired...) there is no way how the user could refresh a page in the non-existing session. This explains why you shouldn't depend on it; you need to store the URL somewhere.
     
    Question: and how to notify the user? i don't think you mean email because if u mean email, what will be the difference if i send the email inside the service class or in afterOperation method in controller?
    Answer: You didn't read that carefully. Let me quote myself too: "Then either persist the URL in database, or send it to a user (e.g. by email). In theory, you could utilize afterOperation() method of the controller to notify user directly after an asynchronous processing completes, but [....]".
    As you see, I explicitly mentioned email as an option, so it's strange you think I didn't meant that. Also, I never said you should do it in afterOperation(); I explained why you should use one the the two options I suggested (storing the URL or send it to the user) instead of just adding a notificafion (an infolog message) in afterOperation(). Also, this isn't applicable at all if you want talk about a batch only and ignore the other asynchronous modes.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 527 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 473

#3
Adis Profile Picture

Adis 284 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans