Solved

CFLOOP time out

Posted on 2012-03-20
9
640 Views
Last Modified: 2012-04-18
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
Comment
Question by:gdemaria
9 Comments
 
LVL 7

Expert Comment

by:micropc1
ID: 37744935
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
 
LVL 39

Author Comment

by:gdemaria
ID: 37745337
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
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 37748769
wrap ur cfloop inside cftimer to check and see what is the time to get
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 36

Accepted Solution

by:
SidFishes earned 500 total points
ID: 37752427
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
 
LVL 39

Author Comment

by:gdemaria
ID: 37758434
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
 
LVL 39

Author Comment

by:gdemaria
ID: 37758442
> 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
 
LVL 36

Expert Comment

by:SidFishes
ID: 37759063
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
 
LVL 39

Author Comment

by:gdemaria
ID: 37759125
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
 
LVL 36

Expert Comment

by:SidFishes
ID: 37860687
did you ever figure out what was causing the problem?
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question