Code Comments
Programming Forum and web based access to our favorite programming groups.Hi all, I think I'm having a problem with my browser timing out because my cgi script is taking too long. The script processes some database records. When it does 250 of them, it takes about a minute or so, and the browser has no problem. But when I do more, the script takes about 2 or 3 minutes, and the browser gets an incomplete response. Is there a way to tell the browser to hang around a bit longer to wait for a response? Or is there another way to keep the browser's attention so it knows it has a "live connection" and to wait? Thanks, Denzil __________________________________ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail
Post Follow-up to this messageDenzil Kruse wrote: > Hi all, > > I think I'm having a problem with my browser timing > out because my cgi script is taking too long. The > script processes some database records. When it does > 250 of them, it takes about a minute or so, and the > browser has no problem. But when I do more, the > script takes about 2 or 3 minutes, and the browser > gets an incomplete response. It's probably the server timing out and not the browser. > > Is there a way to tell the browser to hang around a > bit longer to wait for a response? Or is there > another way to keep the browser's attention so it > knows it has a "live connection" and to wait? One way is to have the CGI script output some data periodically. For a more sophisticated approach, see http://www.stonehenge.com/merlyn/We...ques/col20.html
Post Follow-up to this message--- Bob Showalter <Bob_Showalter@taylorwhite.com> wrote: > It's probably the server timing out and not the > browser. > Okay, I'll see if I can change that. > One way is to have the CGI script output some data > periodically. I tried that but it didn't work. I'll do it again and make sure I hit everywhere in the algorithm. > > For a more sophisticated approach, see > http://www.stonehenge.com/merlyn/We...ques/col20.html > Thanks, I'll take a look Denzil __________________________________ Do you Yahoo!? The all-new My Yahoo! - Get yours free! http://my.yahoo.com
Post Follow-up to this message--- Bob Showalter <Bob_Showalter@taylorwhite.com> wrote: <snip> > a > > One way is to have the CGI script output some data > periodically. I tried that, but it didn't matter much. What happens is I have a link. When I click on it, the browser hangs. If I switch to another application on my desktop whose window covers the browser, and then I switch back to the browser, the graphics of the browser is not redrawn. I use IE, and the windows logo isn't spinning and and green progress bar is going nowhere. Then, after about 30 seconds, the browser recieves some partial html code and stops. The html is cut off, and doesn't correspond to the point in the code where the time consuming loop is. I see the process still going on the server, and know it completes everything it is supposed to. I checked the apache conf file, and Timeout is set to 300. I don't know if that's the right variable for this. Why would it cut out after only 30 seconds? Denzil __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com
Post Follow-up to this messageOn Dec 30, 2004, at 1:54 PM, Denzil Kruse wrote: > > --- Bob Showalter <Bob_Showalter@taylorwhite.com> > wrote: > <snip> > > I tried that, but it didn't matter much. What happens > is I have a link. When I click on it, the browser > hangs. If I switch to another application on my > desktop whose window covers the browser, and then I > switch back to the browser, the graphics of the > browser is not redrawn. I use IE, and the windows > logo isn't spinning and and green progress bar is > going nowhere. > > Then, after about 30 seconds, the browser recieves > some partial html code and stops. The html is cut > off, and doesn't correspond to the point in the code > where the time consuming loop is. I see the process > still going on the server, and know it completes > everything it is supposed to. > > I checked the apache conf file, and Timeout is set to > 300. I don't know if that's the right variable for > this. Why would it cut out after only 30 seconds? If I'm not mistaken, there may be some buffering going on, so what you see on your browser may not be what has actually been "sent"; it may be buffered. You may want to consider turning off buffering for the block. I've never had the issue, but others may be able to comment on buffering and how it relates to cgi scripts. Sean
Post Follow-up to this messageOn Thu, 30 Dec 2004, Denzil Kruse wrote: > I tried that, but it didn't matter much. What happens is I have a > link. When I click on it, the browser hangs. If I switch to another > application on my desktop whose window covers the browser, and then I > switch back to the browser, the graphics of the browser is not > redrawn. I use IE, and the windows logo isn't spinning and and green > progress bar is going nowhere. When I have a situation like this, I leave the web browser and start debugging via other means. Two options that come to mind are lynx and telnet. lynx is a text-mode web browser that is available for Windows via Cygwin; you run it in a DOS window. lynx has a very useful '-mime_header' command line option that outputs the full, raw results of a request to the console. For example, here's what a request to Google.com looks like: $ lynx -mime_header http://google.com/ HTTP/1.0 302 Found Location: http://www.google.com/ Set-Cookie: PREF=ID=02bcd50c22028675:TM=1104438517:L M=1104438517:S=RDEtbY9uE aUVr5ze; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com Content-Type: text/html Server: GWS/2.1 Content-Length: 152 Date: Thu, 30 Dec 2004 20:28:37 GMT Connection: Keep-Alive <HTML><HEAD><TITLE>302 Moved</TITLE></HEAD><BODY> <H1>302 Moved</H1> The document has moved <A HREF="http://www.google.com/">here</A>. </BODY></HTML> $ For testing your own site, you can do the same thing: $ lynx -mime_header "http://mysite/cgi-bin/test.pl?a=1&b=2" It's also possible to manually interact with the remote web server by opening up a telnet sesstion to the web port. Here's an example; the lines where I type things are prefixed with a '->' marker: -> $ telnet www.google.com 80 Trying 64.233.187.99... Connected to www.google.com. Escape character is '^]'. -> HEAD / HTTP/1.0 -> HTTP/1.0 200 OK Cache-Control: private Content-Type: text/html Set-Cookie: PREF=ID=38c23118a0763701:TM=1104438717:L M=1104438717:S=goAOAnKfb 7EPl0ha; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com Server: GWS/2.1 Content-Length: 0 Date: Thu, 30 Dec 2004 20:31:57 GMT Connection: Keep-Alive Connection closed by foreign host. $ This can be useful, but it means you have to know how to "speak" HTTP to a web server -- not that that's very hard, as there's only half a dozen words or so in the whole HTTP "language", and the only ones you'd care about in most cases are GET, POST, and HEAD. But if you want to skip that, just use `lynx -mime_headers $URL`, or an equivalent such as the command line tools that are installed [on Unix systems] with Bundle::LWP from CPAN. In this way, you should be able to see pretty clearly where things are breaking down, and you won't be distracted by what the browser is doing in the background, because it won't *be* in the background. -- Chris Devers
Post Follow-up to this messageOn Thu, Dec 30, 2004 at 10:54:00AM -0800, Denzil Kruse wrote: > I checked the apache conf file, and Timeout is set to > 300. I don't know if that's the right variable for > this. Why would it cut out after only 30 seconds? TMK that is the correct default value. However there is probably a work around. You may be running into an output buffering problem. In otherwords, your script may be waiting to output/print data until after it's buffer is full (probably ~4096 bytes). You can over-ride this behavior by setting $|=1 (see: `perldoc perlvar`). Hope that helps. -- ===================== Shaun Fryer ===================== http://sourcery.ca/ ph: 416-544-9461 =====================
Post Follow-up to this messageOn Wed, 29 Dec 2004 16:17:45 -0800 (PST), denzilphp@yahoo.com (Denzil Kruse) wrote: >Hi all, > >I think I'm having a problem with my browser timing >out because my cgi script is taking too long. The >script processes some database records. When it does >250 of them, it takes about a minute or so, and the >browser has no problem. But when I do more, the >script takes about 2 or 3 minutes, and the browser >gets an incomplete response. > >Is there a way to tell the browser to hang around a >bit longer to wait for a response? Or is there >another way to keep the browser's attention so it >knows it has a "live connection" and to wait? > >Thanks, >Denzil Merlyn wrote an article which is often referred to in discussion of this problem. Linux Magazine Column 39 (Aug 2002) http://www.stonehenge.com/merlyn/LinuxMag/col39.html There are a few other ways you can approach the problem. If you control the server, you can increase it's timeout value, otherwise you will need to setup a scheme to fork-and-exec the long process, then come back later and get the results. -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html
Post Follow-up to this message--- Shaun Fryer <sfryer@sourcery.ca> wrote: <snip> > > TMK that is the correct default value. However there > is probably a > work around. You may be running into an output > buffering problem. > In otherwords, your script may be waiting to > output/print data until > after it's buffer is full (probably ~4096 bytes). > You can over-ride > this behavior by setting $|=1 (see: `perldoc > perlvar`). Hope that > helps. > That did the trick! Thanks for the help everyone. Denzil __________________________________ Do you Yahoo!? All your favorites on one personal page – Try My Yahoo! http://my.yahoo.com
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.