Last post Jul 09, 2014 10:34 PM by Starain chen - MSFT
Jul 08, 2014 10:37 AM|Jerry8989|LINK
I have a web site that has been in existence since 2006. I'm taking it over now and I want to get some suggestions on the best way to approach the communications between the client browser and the web server and database. Currently A user logs into my
website and can go through and select many different data fields. Then they can select in what type of format they want the data to be generated. At this point a SAS job is executed on the web server which calls a macro on a linux server. This process my
take some time because some users have selected about 20,000 columns and 45,000 rows. After that part completes I create an excel file or pdf on the web server which also takes a lot of time. While these processes are running the browser doesn't know what
is happeneing and eventually times out. What would be a better approcach to do this? I'm using a process to execute the sas software on the web server which will run the job based on the users selection. I can't figure out in the old program what settings
are causing it not to time out.
Thank you for any help you could possible give me.
Jul 08, 2014 11:02 AM|AidyF|LINK
You need to put a queue system between the browser request and the actual task being run. Make your browser write the details of the job, such as the parameters of it and who is requesting it, into a queue mechanism. This could be a database table, an
MSMQ queue etc, or even a file written to a drop folder, whatever you want. Now you need a scheduled task or a listener that picks up the presence of the task and runs it and stores the results (the pdf file or whatever) and updates the job to say that job
has been done. The browser can see the progress of any jobs for that user and if the job has finished they can direct the user to the location of the PDF file which would have been recorded with the job status.
Jul 08, 2014 12:15 PM|wavemaster|LINK
I would send the user notification when the xls/pdf file is available and they can download it then.
Jul 08, 2014 12:47 PM|Jerry8989|LINK
Thank you for your reply. This is an on demand process so I can't use a scheduled task. Will the listener be a windows service? How will it know that a user has sent a request?
I do have a queue system in place now. The job gets attached an id and put into a table and at the end of the process an update with the ending date and time is made to that row.
Thank you again for your help.
Jul 08, 2014 01:24 PM|AidyF|LINK
Forgot to mention the listener bit. If it's a service it can process each minute, if it's MSMQ you get notifications when a message has arrived, if you use files in a folder you can use the file watcher to tell you when files have arrived. If you really
expect the client browser to sit and wait until the task is done then you're just going to run into issues with people refreshing as they get impatient and your server will run out of threads.
Jul 08, 2014 04:09 PM|Jerry8989|LINK
I do have a gif that spins to let the user know the job is running. I have it displayed saying the job is being generated. Most of our users know there are large amounts of data and it takes time to create and get it ready for them.
What would you suggest instead of just showing them a spinning circle? Should I use a progress bar or ajax panel to do the waiting?
I'm hoping to find a way to display to the user that the job is running and not let the web browser and server lose their connection.
Jul 09, 2014 05:22 AM|Starain chen - MSFT|LINK
For this requirement, please take a look at PageAsyncTask class:
# PageAsyncTask Class
# ASP.NET MVC 4/RC, Web Forms and Web API Asynchronous samples
Jul 09, 2014 09:08 AM|Jerry8989|LINK
Thank you for the suggestions. My process is synchronous so one step has to complete before the next step begins. I just want to make sure the browser can stay connected during this processes. Some steps take over 5 minutes which causes the firefox
browser to time out.
Jul 09, 2014 10:34 PM|Starain chen - MSFT|LINK
My process is synchronous so one step has to complete before the next step begins.
You could let the whole process in the asynchronous thread. After that, it won’t break other threads.
I just want to make sure the browser can stay connected during this processes
The Http request is stateless, we can’t keep the connection. If you want to keep the connection, you should use socket. For this, I suggest that you could use SignalR, more information, please refer to:
# Introduction to SignalR
Some steps take over 5 minutes which causes the firefox browser to time out
For the timeout issue, you could specify the longer time:
# httpRuntime Element