WinBatch® Technical Support Forum

All Things WinBatch => WebBatch => Topic started by: jazzy495 on October 06, 2014, 11:27:48 AM

Title: WebBatch Interactive Response Web Page
Post by: jazzy495 on October 06, 2014, 11:27:48 AM
I have a WebBatch script that was migrated from Windows Server 2000 to Windows Server 2008 R2 (64-bit). The WebBatch code has different behavior now that it is on 2008 R2. When the WebBatch script was called on Windows Server 2000 the user would get web page updates at each step of the WebBatch script. Now that the WebBatch is running on Windows Server 2008 R2 - the user gets no updates until the entire script is done and then they appear to get the whole page at the same time. Here's an example script I wrote to show what was happening:


WebOut("Content-type: text/html",2)     
WebOut("<html><body>",1)
WebOut('Step 1 of 3 - Submitting batch job',1)
TimeDelay(5) 
WebOut('Step 2 of 3 - Processing Data',1)
TimeDelay(5) 
WebOut('Step 3 of 3 - Done',1)
TimeDelay(5) 
WebOut(' Finished',1)
WebOut('</body></html>',1)


When this SimpleOutput.web WebBatch program ran on Windows Server 2000 the user gets a browser response "Step 1 of 3 - Submitting Batch Job" then 5 seconds later they get the message "Step 2 of 3 - Processing Data", then 5 seconds later they would get "Step 3 of 3 - Done" then 5 seconds later they get the "Finished" message that completes the job. So you can understand that the user got frequent updates in their IE browser along the way of the status of the job.

Now that the SimpleOutput.web WebBatch program is running on Windows Server 2008 R2 (64-bit) this step by step update to the client browser no longer works. Now what happens is the user calls SimpleOutput.web and the client gets a blank browser for 15 seconds then all at once gets a response that is all the Steps at once. Now the user complains that the system is 'hanging up' and not responsive so they hit the back button (oh no!) and rerun the SimpleOutput.web again.

How can I get my SimpleOutput.web WebBatch program to send regular step by step updates to the browser as it runs so that the user knows what step the program is on at any given moment? 

Thank you in advance for your support,

Bruce
Title: Re: WebBatch Interactive Response Web Page
Post by: td on October 06, 2014, 03:02:38 PM
Obviously, IIS 7.* is buffering output in the standard output buffer until the buffer is closed when the WebBatch ends execution.  I am not aware of any IIS setting that changes that behavior. 

Perhaps someone else can think of a better idea but you could dump some javaScript to the browser that would periodically call back to the server with a parameter.  WebBatch could then use the parameter to determine the message to send back to the browser.
Title: Re: WebBatch Interactive Response Web Page
Post by: Windowless on May 05, 2015, 05:32:12 PM
responseBufferLimit=0 should be set in the IIS configuration on the server.
Title: Re: WebBatch Interactive Response Web Page
Post by: td on May 06, 2015, 08:24:40 AM
Better late than never.  It does appear that IIS 7.5 does have a 'responsBufferLimit' property and has been reported that setting the property to 0 resolves similar issues.

Thanks for bringing it to our attention.
Title: Re: WebBatch Interactive Response Web Page
Post by: jazzy495 on January 03, 2018, 07:12:39 AM
<SOLUTION>
I did some testing in my test lab and confirmed your comment about response buffer limit is the correct solution. I have been plagued with this issue for three years. I revisited this issue this year because my users are still complaining that the web page hangs up for 3 minutes while a process is running. My web page was designed to show the user STEP01, STEP02, STEP03 progress along with OK or ERROR at each step. After upgrading to IIS 7.5 this completely broke and I was lost to figure out how to fix it without rolling back. I wanted to either 1) start the process and move on or 2) Provide step-by-step feedback while the job is running. Both solutions require the RunShell() with @NOWAIT or the Run() to be used.  The RunShell() with @NOWAIT feature was not working correctly and would hang until the command was done executing. Once I made the following changes the web page was interactive and the RunShell @NOWAIT would move smoothly past the command execution and leave it to complete while the web page and WebBatch continued moving forward. This solution works for IIS 7.5+

1. Open IIS Manager and go to Connections > WebSite > Handler Mappings and click on the webcgi subfolder from the root. Go to Handler Mappings and look at the CgiModule handler. Get the name of the handler. Mine is CGI-exe.
2. Open a cmd as administrator
3. cd c:\windows\SysWOW64\inetsrv

To Get Current Setting
4. appcmd.exe list config /section:handlers | Find "CGI-exe"
   My before change setting:
   <add name="CGI-exe" path="*.exe" verb="*" modules="CgiModule" resourceType="File" requireAccess="Execute" allowPathInfo="true" />

To set the response buffer limit to 0
5. appcmd.exe set config /section:handlers "/[name='CGI-exe'].ResponseBufferLimit:0"
   My after change setting:
       <add name="CGI-exe" path="*.exe" verb="*" modules="CgiModule" resourceType="File" requireAccess="Execute" allowPathInfo="true" responseBufferLimit="0" />

6. Done!
</SOLUTION>

When you compare the two outputs from step 4 and step 5 and you will notice after the change that the CgiModule has the responseBufferLimit set to "0". This is all that was needed to get the web page to be interactive. Now I can kick off a process without having the user wait for the response in IIS 7.5. Just in time to upgrade to IIS 10.  :D

Happy 2018!    Best Regards,

Bruce

Title: Re: WebBatch Interactive Response Web Page
Post by: td on January 03, 2018, 08:38:11 AM
Good to know it works.