Search code examples
delphiiis-7.5isapiindy-9

Controlling a long running and critical ISAPI process


Scenario:

  • Client makes ISAPI call with POST to IIS 7.5 server - the call will generate mission critical output to be distributed to numerous users. (using Delphi XE with Indy 9 HTTP client in this case);
  • ISAPI process takes a LONG TIME to complete (it's threaded on the client side);
  • Before the POST call returns, user aborts or client machine goes down, killing client side connection and leaving the ISAPI process chugging away on the IIS 7.5 server.

Questions:

  • What does IIS 7.5 do with that thread, which is still executing when the client/user aborts and kills the connection?
  • Will the server side thread complete processing even though the client has disconnected, or will IIS 7.5 kill that thread at some point, perhaps leaving a mess in the aborted process?
  • Is this time dependent - depending on how long it takes for the server-side process to complete?
  • Can this be controlled - can I instruct IIS to complete the process even though the client has aborted? If so, how?

Solution

  • IIS will continue to process until completion, or until the timeout for the App Pool is hit.

    You should look at using Indy's TIdHTTPServer and then you'll control the server side which will allow you to setup your own rules on how to handle a long and possibly disconnected client session instead of becoming an expert in IIS AppPool management.