7 Replies Latest reply on Dec 5, 2009 3:17 AM by BKBK

    ColdFusion hanging

    anthonyswu

      Hi,

       

      I have a ColdFusion 8 application that connects to a MySQL 5.1 database.  Client variables are stored in the database.  Every so often (once every few days or so), one of our users will experience a hanging issue, usually triggered by the user attempting to log in and start a new session.  And once the user triggers this hanging issue, all other pages (session or non-session pages) experience this hang, even if called under another browser session.  I'm wondering if this is a session issue or something to do with the cfapplication tag?

       

      This seems to happen with users using MSIE as their browser, although I can't be certain this is always the case.  I should also note that the login section of our site starts a secure (SSL) session, although I'm not sure if this has anything to do with the hanging issue.

       

      Finally, I should note that my application is hosted on a shared server.  I don't believe that shared traffic is the issue here though because in troubleshooting this issue with my hosting company, they actually moved my site to a dedicated server and we still experienced the hanging issue periodically.

       

      I've been troubleshooting this issue with my hosting company for almost two months now with no fix.  I've searched all the forums and although I've seen other posts regarding ColdFusion hanging (mostly in MX), they do not seem to address the same issue I'm having.

       

      Has anyone else experienced this problem and found a fix?

       

      Thanks,

      Tony

        • 1. Re: ColdFusion hanging
          BKBK Adobe Community Professional & MVP
          one of our users will experience a hanging issue, usually triggered by the user attempting to log in and start a new session.  And once the user triggers this hanging issue, all other pages (session or non-session pages) experience this hang, even if called under another browser session.

          My immediate thought is: session variables are confused with application variables somewhere. Could we see the code in your application file?

          • 2. Re: ColdFusion hanging
            anthonyswu Level 1

            Yes, here is code from my login page that starts the user's session:

             

            <cfquery name="GetUser" datasource="SiteDB" maxrows="1">
            select * from USERS
            where USERNAME = '#Username#' and PASSWORD = '#Password#'
            </cfquery>

            <cfif isDefined("Client.User_ID")>
            <cfset Deleted = DeleteClientVariable("User_ID")>
            </cfif>

            <cfapplication name="UserSession"
            clientmanagement="Yes"
            clientstorage="SiteDB"
            setclientcookies="Yes"
            sessionmanagement="Yes"
            sessiontimeout="#createTimeSpan(1,0,30,0)#"
            applicationtimeout="#createTimeSpan(1,0,30,0)#"
            setdomaincookies="No">

            <cfset Client.User_ID = #GetUser.ID#>

            <cfcookie name="SiteUser" value="#GetUser.ID#" expires="Never">
            <cfif isDefined("AutoLogin")>
            <cfcookie name="SiteLogin" value="#GetUser.ID#" expires="Never">
            </cfif>

             

            And here is the code my my application.cfm file:

             

            <cfapplication name="UserSession"
            clientmanagement="Yes"
            clientstorage="SiteDB"
            setclientcookies="Yes"
            sessionmanagement="Yes"
            sessiontimeout="#createTimeSpan(1,0,30,0)#"
            applicationtimeout="#createTimeSpan(1,0,30,0)#"
            setdomaincookies="No">

            <cfif isDefined("Client.User_ID")>

            <cfquery name="GetUser" datasource="SiteDB" maxrows="1">
              select *
              from USERS
              where ID = #client.User_ID#
            </cfquery>

            <cfif GetUser.recordCount gt "0">

               <cfquery name="RecordUserHit" datasource="SiteDB">
                update USERS
                set HITCOUNT = HITCOUNT + 1,
                 LASTHIT = #Now()#
                where ID = #client.User_ID#
               </cfquery>

            <cfelse>

              <cfoutput>
               <script language="JavaScript">
                top.location.replace("../index.cfm");
               </script>
              </cfoutput>
              <cfabort>
             
            </cfif>

            <cfelse>

            <cfoutput>
              <script language="JavaScript">
               top.location.replace("../index.cfm");
              </script>
            </cfoutput>
            <cfabort>

            </cfif>

             

            Thanks for your help.

            • 3. Re: ColdFusion hanging
              BKBK Adobe Community Professional & MVP

              Two things jump out at me:

              1) the cfapplication tag in the login page. It doesn't belong there. Remove it. If you leave it there, then the application will be reset whenever the login page is opened.

              2) you call the application file application.cfm. I hope you have saved it as Application.cfm, with capital A.

              • 4. Re: ColdFusion hanging
                anthonyswu Level 1

                Thanks.  I'll remove the cfapplication tag from my login page.  Will this solve the hanging issue though?  I'm now reading up on whether I should be using client or session variables and whether that has anything to do with the hanging issue as well.  I'm using client variables but I don't really have anything that I have to maintain persistently across sessions, so I may switch to session variables.  I'm hoping that in doing so, that will: (1) solve the hanging issue; and (2) speed up my site in general since there are fewer database requests.  Any thoughts on this?

                • 5. Re: ColdFusion hanging
                  anthonyswu Level 1

                  Follow-up question.  I'm trying to remove the cfapplication tag from my login page.  But how do I set the initial client variable (to indicate that the user is now logged in) without first calling the cfapplication tag?  When I remove that tag I get an error "The requested scope CLIENT has not been enabled."

                   

                  I tried switching to session variables hoping that I could set a session.User_ID variable without first calling a cfapplication tag.  This worked but then I lost the session variable when I pulled up the member page (I think because I switched from http to https)?

                  • 6. Re: ColdFusion hanging
                    BKBK Adobe Community Professional & MVP
                    I'll remove the cfapplication tag from my login page.  Will this solve the hanging issue though?

                    Well, there's only one way to find out.

                     

                    I'm using client variables but I don't really have anything that I have to maintain persistently across sessions, so I may switch to session variables.  I'm hoping that in doing so, that will: (1) solve the hanging issue; and (2) speed up my site in general since there are fewer database requests.  Any thoughts on this?

                    I think, everything being equal, 2) is good enough reason to switch to session variables.

                    • 7. Re: ColdFusion hanging
                      BKBK Adobe Community Professional & MVP

                      Follow-up question.  I'm trying to remove the cfapplication tag from my login page.  But how do I set the initial client variable (to indicate that the user is now logged in) without first calling the cfapplication tag?  When I remove that tag I get an error "The requested scope CLIENT has not been enabled."

                       

                      I tried switching to session variables hoping that I could set a session.User_ID variable without first calling a cfapplication tag. This worked but then I lost the session variable when I pulled up the member page (I think because I switched from http to https)?

                       

                      Technically, the tag is included in the login page anyway. The tag is in Application.cfm, and Coldfusion automatically includes the content of Application.cfm in every request, hence also in the request for the login page.

                       

                      You should rule out the obvious. Coldfusion wont see the content if you save the file as application.cfm, with small letter a. In addition, you have to enable the use of application variables and session variables in the Coldfusion Administrator.