8 Replies Latest reply on Dec 16, 2016 4:04 AM by user19752

    Can't decrease PHP execution/timeout time (FM

    stevepony

      Dear all,

       

      I'm having an issue with the timeout/execution time using PHP. What I'm trying to do is test whether a Filemaker Database is available or not by using below script:

       

      $connected = $fm->listLayouts(); if(FileMaker::isError($connected)) { die('Error - ' . $connected->getCode() . ' ' . $connected->getMessage()); }

       

      Problem is it takes the script 60sec to show below error:

      Error - 7 Communication Error: (7) Failed to connect to 103.22.180.61 port 80: Connection timed out

       

      This is too long. Is there a way to script in PHP to try connecting to the database and if it doesn't work within 10sec, just stop trying to connect and show the error (or do anything else) right away? I tried...

       

      set_time_limit(10); //OR ini_set('max_execution_time', 10); if(FileMaker::isError($connected)) { die('Error - ' . $connected->getCode() . ' ' . $connected->getMessage()); }

       

      But it didn't work. Still 60 sec. Any ideas on that? I did trying to research on my own for an hour already, without any success... Thank you so much!

        • 1. Re: Can't decrease PHP execution/timeout time (FM
          stevepony

          P.S.: Ummm, I added the PHP code nicely as "Raw Html", but now it looks very bad. How come? How can I properly insert code in this forum?

          • 2. Re: Can't decrease PHP execution/timeout time (FM
            user19752

            If there is error on connection, it should be caught on creating $fm, not $connected.

            • 3. Re: Can't decrease PHP execution/timeout time (FM
              stevepony

              Dear user19752,

               

              Thank you, I tried as below, but it did not work. I think either I did something wrong or can't catch an error on $fm? It's only $fm =& new FileMaker();

               

              if(FileMaker::isError($fm)){

                die('Error - ' . $fm->getCode() . ' ' . $fm->getMessage());

                }

               

              Anyway the $connected script I found in the internet, many pages suggest doing it this way.

              >> But this is not the main issue anyway. The script works. But the timeout of 60sec trying to connect to the Database until it finally fails and gives me the error, that's the problem.

               

              Any idea? Thanks again!

              • 4. Re: Can't decrease PHP execution/timeout time (FM
                stevepony

                Just got this reply at Stackoverflow:

                 

                max_execution_time or set_time_limit purely only for PHP script. If connection to Filemaker maybe timeout set somewhere else in the Filemaker configuration.

                From PHP Doc;

                Note: The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. This is not true on Windows where the measured time is real.

                Is there a way to decrease the timeout time for the PHP request to Filemaker Server?

                • 5. Re: Can't decrease PHP execution/timeout time (FM
                  stevepony

                  I found in the "Manual" this:

                   

                  Error 1629: Connection timed out; the timeout value is 60 seconds

                  >> So I think my question is, how to decrease those 60 seconds to 10 manually?

                  • 6. Re: Can't decrease PHP execution/timeout time (FM
                    user19752

                    Ouch, very sorry, creating FileMaker object does nothing to connect, so you were correct. Some action with $fm will try connecting.

                     

                    PHP API use curl to connect database internally, so you may need setting curl option, I don't know how do it.

                    You would need editing FileMakerImpl.php that has lines like

                    curl_setopt($Vd88fc6ed, CURLOPT_HEADER, true);

                    • 7. Re: Can't decrease PHP execution/timeout time (FM
                      stevepony

                      Ok no worries.

                       

                      Oh dear, I don't have any idea as well.

                      >> Editing FileMakerImpl.php isn't an option in our case, I think.

                      Reason: Basically the 60sec are ok, in case the connection is slow. I just wanted it faster for the test connection.

                       

                      Background of the whole thing: We are having problems with our hosting provider and their server, where Filemaker Server is running. I just want to prevent people are waiting 1 minute (when registering for an event), and after 1 minute they receive an error. My plan is - see if the connection works, if so, go ahead. But if not, Plan B: Save the pure data somewhere else and don't show funny errors to the client + loose the data.

                       

                      Now I guess I could only switch to "emergency" plan after 60 sec. But it's so long... :-(

                      • 8. Re: Can't decrease PHP execution/timeout time (FM
                        user19752

                        Hmm, I wrote "edit" but it is not need, you can write additional code connecting to XML interface which is used by PHP API then set time out for it.