7 Replies Latest reply on Jul 20, 2006 11:33 AM by Newsgroup_User

    cfhttp and timeout

    leesiulung
      I'm using cfhttp with a timeout value, but how do I know if I timed out?

      Can't seem to find any examples online or at the macromedia livedocs. Perhaps, it returns a statuscode 408. How can I test this sort of thing?
        • 1. Re: cfhttp and timeout
          Level 7
          If the cfhttp call times out it throws an ColdFusion Exception (Unless
          the don't throw exception option is selected IIRC). You would handle
          this with any of the ColdFusion Exception handling features.

          <cftry...><cfcatch...>

          And|Or

          <cferror>

          And|Or

          The Administrator Error settings

          To name a couple.

          leesiulung2006 wrote:
          > I'm using cfhttp with a timeout value, but how do I know if I timed out?
          >
          > Can't seem to find any examples online or at the macromedia livedocs. Perhaps,
          > it returns a statuscode 408. How can I test this sort of thing?
          >
          • 2. cfhttp and timeout
            jdeline Level 1
            <CFOUTPUT>#CFHTTP.FileContent#</CFOUTPUT> will show you the 408 error. Go to http://livedocs.macromedia.com/coldfusion/5.0/CFML_Reference/Tags47.htm#1632966 for more information.
            • 3. Re: cfhttp and timeout
              leesiulung Level 1
              jdeline,

              I am aware of the filecontent and the return value of cfhttp. However, can I assume that after the "call" to cfhttp tags the cfhttp.Responseheader.Status_Code will always be filled out afterwards? Is this how I get notified of a 408 Timeout?

              Seems like the documentation although available seems to be missing detailed information about how to handle things or it is me who is not as familiar with how html pages with headers etc... are handled.

              thanks jdeline!
              • 4. Re: cfhttp and timeout
                leesiulung Level 1
                Ian,

                For some reason your post did not show up the previous time I viewed it although you posted before jdeline... wierd.

                Anyhow, I turned off throwonerror, but for the future. How do I know that this particular timeout error occured and not something else if I use cftry/catch. The error type that "catch" catches is not clear (there are only like 10 different kinds).

                In programming languages like java there are exceptions with a type (class) that indicates what happened in a try/catch clause.
                • 5. cfhttp and timeout
                  leesiulung Level 1
                  duplicate post,

                  is it me or adobe web site soooo slow....
                  • 6. Re: cfhttp and timeout
                    Level 7
                    There are two states involved here. If the remote server returns an
                    HTTP error, even a timeout one, that is NOT a <cfhttp> timeout error.
                    <cfhttp> go a response, the http error message and that response will be
                    placed into the <cfhttp> response structure. So yes, you can count on
                    the status_code being any status_code the remote server returned, and
                    the filecontent to be any file content returned.

                    The <cfhttp...> timeout parameter is how long the process will wait for
                    any response from the remote server. If no response, http error or
                    otherwise, is received within the specified time limit cfhttp will throw
                    a ColdFusion exception that you handle with ColdFusion exception
                    handling functions.

                    So you have two questions to ask when working with <cfhttp...>. Did I
                    get a response? And if so, what was that response?

                    leesiulung2006 wrote:
                    > jdeline,
                    >
                    > I am aware of the filecontent and the return value of cfhttp. However, can I
                    > assume that after the "call" to cfhttp tags the
                    > cfhttp.Responseheader.Status_Code will always be filled out afterwards? Is this
                    > how I get notified of a 408 Timeout?
                    >
                    > Seems like the documentation although available seems to be missing detailed
                    > information about how to handle things or it is me who is not as familiar with
                    > how html pages with headers etc... are handled.
                    >
                    > thanks jdeline!
                    >
                    • 7. Re: cfhttp and timeout
                      Level 7
                      When you use <cfcatch> ColdFusion builds an exception structure named
                      "cfcatch". This will include the exception type and other data. You
                      can start by <cfdump var="#cfcatch#"> and it will show all the data
                      about the exception.

                      You can also type your <cfcatch type="database"...> blocks. This allows
                      you to build different exception handling code for different potential
                      exceptions.

                      And remember, with <cfhttp...> Receiving a http error is NOT an
                      exception. As far as <cfhttp> is concerned a result was returned. It
                      is up to you to examine that result and determine if it is an expected
                      result or not. You would use the #cfhttp# structure (or other named
                      structure if using MX7+) to examine the result.

                      You can use the <cfthrow...> tag if you would like to throw a custom
                      exception to your try/catch logic based on the result returned by <cfhttp>

                      HTH


                      leesiulung2006 wrote:
                      > Ian,
                      >
                      > For some reason your post did not show up the previous time I viewed it
                      > although you posted before jdeline... wierd.
                      >
                      > Anyhow, I turned off throwonerror, but for the future. How do I know that this
                      > particular timeout error occured and not something else if I use cftry/catch.
                      > The error type that "catch" catches is not clear (there are only like 10
                      > different kinds).
                      >
                      > In programming languages like java there are exceptions with a type (class)
                      > that indicates what happened in a try/catch clause.
                      >