Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 679
  • Last Modified:

CFLOOP time out

I'm getting an odd timeout error when looping through the user agent to see if it's a bot.

It seems to be a simple string loop.. has anyone experience this before?   Any suggestions?
This code exists in my application.cfc file inside the onError function.

This code has been in place for over a year, every now and then this happens.  If I comment it out, everything works fine.  Later, I make it active again and it works for a while..  right now it throws the error every time I open any page.


The request has exceeded the allowable time limit Tag: CFLOOP    
The error occurred in D:\inetpub\stageRoot\PRODUCTS\ApplicationGlobal.cfc: line 76
 
75 :               <cfset isABot = true>
76 :               <cfbreak>
77 :            </cfif>
78 :         </cfloop>

 




<cfif isDefined("CGI.HTTP_USER_AGENT") and Len(CGI.HTTP_USER_AGENT)>
    <cfset theAgent = CGI.HTTP_USER_AGENT>
      <cfloop list="bot\b,crawl,\brss,feed,news,blog,reader,syndication,coldfusion,slurp,google,zyborg,emonitor,jeeves,msnbot" index="bot" delimiters=",">
            <cfif findNoCase(bot, theAgent)>
	    <cfset isABot = true>
                     <cfbreak>
            </cfif>
       </cfloop>
  </cfif>
  <cfif isABot>
       <h2>This session has been identified as a search engine spider</h2>
       <p>If you are human and not an automated BOT please contact support</p>
       <cfexit>
  </cfif>

Open in new window




Coldfusion 8
0
gdemaria
Asked:
gdemaria
1 Solution
 
micropc1Commented:
You can use <cfsetting requesttimeout="xx"> to increase the timeout limit of your page.

http://livedocs.adobe.com/coldfusion/8/Tags_r-s_18.html
0
 
gdemariaAuthor Commented:
Hey micropc1,
Thanks for the response.  I think looping a couple dozen string elements should take only a fraction of a nano second.   My timeout is already higher than the default due to some bigger equations on some pages.  Any thoughts on why the processing would hang on this simple code to cause the timeout to trigger?
0
 
Gurpreet Singh RandhawaWeb DeveloperCommented:
wrap ur cfloop inside cftimer to check and see what is the time to get
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
SidFishesCommented:
This might be cleaner

<cfif ReFindNocase(bot\b|crawl|brss|feed|news|blog|reader|syndication|coldfusion|slurp|google|zyborg|emonitor|jeeves|msnbot), CGI.HTTP_USER_AGENT>

but I'm a bit confused at this

application.cfc file inside the onError function.

How does onError gets triggered to run the bot check?

I will also note that I had nothing but problems with onError in one of my apps although I can't remember why. (may have been this http://www.raymondcamden.com/index.cfm?mode=entry&entry=ED9D4058-E661-02E9-E70A41706CD89724 but I don't remember)

 Having anything in the onError code block caused it to fail. Ended up going back to app.cfm
0
 
gdemariaAuthor Commented:
Hey Sid,

Thanks for the tip.  I can certainly try that.

The check is done inside the onError file because I don't mind bots spidering through the website,  I just don't like it when the create errors.   So, I don't want to email or log errors if it's just a bot going someplace that no human would go.   Therefore, I check for bots and then just ignore the error if it is one..
0
 
gdemariaAuthor Commented:
> wrap ur cfloop inside cftimer to check and see what is the time to get

Hey myself,

there's a catch-22 here.   When there is no time out, the cftimer shows a nice low reasonable time.  But when there is a time-out, the error is thrown and I get no info, but I assume the time is longer than the time out period..
0
 
SidFishesCommented:
so you're doing a bot check after an error occurs - could it be that the error is causing the timeout rather than the bot check and it just seems to be the loop? (as you noted there's no reason for a simple string loop to cause a time out.)
0
 
gdemariaAuthor Commented:
I guess that's possible and will watch for that, but there are two reasons that make me feel like this is not the case..

- I do have time outs occassionally on long running computations and they don't act this way.
- Removing this cfloop from the onError prevents the error.  That is, I don't get a time out error at all


Thanks for your insights... I will try to put in some logs/cfmail messages to narrow down the situation
0
 
SidFishesCommented:
did you ever figure out what was causing the problem?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now