2 Replies Latest reply on Sep 18, 2012 7:24 AM by steve.winter

    Error 22

    steve.winter

      Hi all

       

      FM 12 solution, updated from FM11, using the API. Single machine install, on Win 2008 server.

       

      Code places a relatively simple find and sort request. approx. 75% of the time it works just fine, approx 25% of the time I get an FM error object back instead

       

      [code] => 22

      [message] => Communication Error: (22) The requested URL returned error: 401 - This can be due to an invalid username or password, or if the FMPHP privilege is not enabled for that user.

       

      Try the same request again, a 'split second' later, and again 75% of the time it works just fine... at present my code literally has;

       

      $res = $cmd->execute();

       

      if(FileMaker::isError($res)) { showMe('broke, trying again');

      $res = $cmd->execute();

      if(FileMaker::isError($res)) { showMe('still broken');

      $success = false;

      $messages[] = 'pSorry, we've not been able to locate the product area you were looking for. Please use the navigation menu above, and then select the specific product or service which you are interested in purchasing.';

      } else { showMe('got it this time');

      $success = true;

      $data = extractRecords($res);

      }

      } else {

      $success = true;

      $data = extractRecords($res);

      }

       

      (Ignore code redundancy I know - this is just 'make it work and track it' code).

       

      So far, I've only seen 'still broken' once, every other time I've got the 'got it this time' response...

       

      Any thoughts...? anyone else seen this...?

       

      Cheers

      Steve

        • 1. Re: Error 22
          DustinMarquise

          Steve,

           

          We had a client report this same "error 22" just last night.  It also was with a file converted from 11 to 12.  They are using a two machine (separate web server and database server) MacOSX set up.  They were not able to connect to the database server at all.  They were using SSL and based on FileMaker support...

           

          If you have configured your web server to allow communication via the SSL port and are using a self-signed certificate or a certificate signed by a Certificate Authority not listed in the truststore, your solution may not be able to communicate with the Web Publishing Engine. If this issue occurs, open the FileMaker API for PHP (filemaker-api.php) on the server, or on a worker machine in a multi-machine configuration, located in this folder:

          Windows
          [drive]:\Program Files\FileMaker\FileMaker Server\Web Publishing\publishing- engine\php\lib\php\FileMaker\conf


          Mac OS X 10.6 (Snow Leopard)
          /Library/FileMaker Server/Web Publishing/publishing-engine/php/Snow Leopard/lib/php/FileMaker/conf

          Mac OS X 10.7 (Lion)
          /Library/FileMaker Server/Web Publishing/publishing- engine/php/Lion/lib/php/FileMaker/conf

          Uncomment this line of code:
          $__FM_CONFIG['curlOptions'] = array(CURLOPT_SSL_VERIFYPEER => false);

          We also had the client manually replace the FileMaker.php and FileMaker folder in the root folder of the web server with the same files that ship with FileMaker 12 Server... can be found at FileMaker Server/Web Publishing/FM_API_for_PHP_Standalone.zip

           

          Not sure if this helps with your situation, but after they did this, restarted the web server and FM Server, everything was working properly again.

           

          Good luck

          Dustin

          • 2. Re: Error 22
            steve.winter

            Hi Dustin

             

            Thanks for your response, unfortunately that doesn't apply to my situation because sometimes it works, and sometimes, it just doesn't. I've set up some test code thus;

             

            /*

              * A function to repeatedly call FM if there is an error 22 returned

              */

            function callDB($cmd) {

                  global $callCount;

                  $res = $cmd->execute();

                  while (FileMaker::isError($res) && $res->code == 22 && $callCount < 10) {

                       $callCount++;

                       // pause for half a second after the 6th and 8th calls

                       if($callCount == 6 || $callCount == 8) {

                            usleep(500000);

                       }

                       $res = $cmd->execute();

                   }

                  print("returning data from call {$callCount}");

                  return $res;

            }

             

             

            // $cmd gets defined

             

            print('<p>');

            for($i=1; $i<51; $i++) {

                set_time_limit(10);

                print("Test {$i}: ");

                $callCount                               = 0;

                $res                                         = callDB($cmd);

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

                   print(" BROKEN: ");

                }

                print("<br />");

            }

            print('</p>');

             

             

            The result of that is;

             

            Test 1: returning data from call 0

            Test 2: returning data from call 0

            Test 3: returning data from call 1

            Test 4: returning data from call 0

            Test 5: returning data from call 2

            Test 6: returning data from call 0

            Test 7: returning data from call 0

            Test 8: returning data from call 3

            Test 9: returning data from call 0

            Test 10: returning data from call 0

            Test 11: returning data from call 1

            Test 12: returning data from call 1

            Test 13: returning data from call 1

            Test 14: returning data from call 1

            Test 15: returning data from call 0

            Test 16: returning data from call 0

            Test 17: returning data from call 1

            Test 18: returning data from call 1

            Test 19: returning data from call 1

            Test 20: returning data from call 0

            Test 21: returning data from call 1

            Test 22: returning data from call 0

            Test 23: returning data from call 1

            Test 24: returning data from call 1

            Test 25: returning data from call 0

            Test 26: returning data from call 0

            Test 27: returning data from call 1

            Test 28: returning data from call 0

            Test 29: returning data from call 0

            Test 30: returning data from call 0

            Test 31: returning data from call 0

            Test 32: returning data from call 0

            Test 33: returning data from call 0

            Test 34: returning data from call 0

            Test 35: returning data from call 1

            Test 36: returning data from call 0

            Test 37: returning data from call 1

            Test 38: returning data from call 0

            Test 39: returning data from call 0

            Test 40: returning data from call 0

            Test 41: returning data from call 0

            Test 42: returning data from call 2

            Test 43: returning data from call 0

            Test 44: returning data from call 0

            Test 45: returning data from call 1

            Test 46: returning data from call 1

            Test 47: returning data from call 0

            Test 48: returning data from call 1

            Test 49: returning data from call 9

            Test 50: returning data from call 0

             

            As you can see, 29 times no error was returned (i.e. data was returned for call 0), 17 times an error 22 was returned once, twice the error came back twice, once three times, and once nine times before on the tenth try a valid response was returned...!

             

            As you can see from the code above, it's the same $cmd which is executed each time... I now have a working solution in place (again) but this indicates that to make 50 requests, the database is actually getting hit 83 times, clearly a performance concern...!

             

            Thanks again. Anyone else...?