7 Replies Latest reply on Oct 16, 2007 11:07 PM by Mitek17

    problems HTTPService

    Mitek17 Level 1
      Hi,

      I guess that there are not so many people who use HTTPService to connect to raw Apache/PHP server, but I'll try anyway.

      There is a client which connects to server using HTTPService. It sends XML and gets back an XML in response from a server.
      The problem I am facing is - sometimes, somehow client sends a request to server and never gets a response back. Instead of it HTTPService throws HTTP request error #2032 after some timeout (~15 mins, even if I set the timeout = 0).

      Server log files show that server side is OK - it gets a request and sends back a response. Problem sits somewhere between server and HTTPService object.

      I am aware about the IE problem with caching over SSL. PHP is set up to send correct pragma-cache headers to disable pages caching. It helped significantly but the problem hasn't gone completely.

      Second thing which I found is probably a memory leak in the HTTPservice. It's getting worse if the same instance of the class works for a long time (by long I mean 6-8 hours). So, I am creating the HTTPService instance just before sending a request and then killing it after response has received. It helped again, but not cured the problem completely.


      The average number of HTTP error requests decreased from 20 per day to 1-2 per day. But the problem is still there.

      Does anyone have any other ideas how to get rid of this nasty problem?

      Thanks!

      Cheers,
      Dmitri.
        • 1. Re: problems HTTPService
          shawnoshawnuth
          In your HTTPService declaration, are you setting a method="post" ?

          Also on the PHP side, how are you returning XML? Are you forcing the XML back into a header or just printing to the screen?
          • 2. Re: problems HTTPService
            Mitek17 Level 1
            Hi Shawn,

            Thank you for replying.

            Yes, I specify the "post" method in the HTTPService.

            quote:

            Are you forcing the XML back into a header or just printing to the screen?

            Shawn, what do you mean by forcing? Probably not, because I am just using the echo operator.

            Here is the excerpt from PHP code which does it:

            function startSession{
            ini_set('session.use_only_cookies', "1");
            ini_set('session.session.cookie_secure', "1");
            ini_set('session.cookie_httponly', "1");
            session_set_cookie_params(0);

            session_cache_limiter("nocache");

            session_start();

            header('Pragma: bogus');
            header('Cache-control: bogus');
            }

            startSession();
            echo '<?xml version="1.0" encoding="UTF-8"?>';
            echo ' <myxml>some</myxml>';



            Cheers,
            Dmitri.


            • 3. problems HTTPService
              Mitek17 Level 1
              I've added to the PHP code buffer flushing command:

              ob_flush();
              flush();

              Still getting timeouts/HTTP errors.


              • 4. problems HTTPService
                _Seth
                Have you tried to access XML from browser?
                Colud you alsow submit a part of Flex code u use to get XML file?
                • 5. Re: problems HTTPService
                  Mitek17 Level 1
                  Hi Seth,

                  Yes, I cam access XML from a browser. The problem is that it fails 1-2 times out of ~100 requests.
                  The code is something like this:

                  //wrapper for HTTPService
                  public class CMyHTTPService extends HTTPService
                  {
                  public function CMyHTTPService()
                  {
                  super.method = "POST";
                  super.requestTimeout = CGlobalParameters.g_iHTTPTimeout; // =0
                  super.addEventListener("fault", fFaultHandler);
                  super.contentType = "application/x-www-form-urlencoded";
                  }
                  }


                  //save appointment. Code is activated by pressing a button

                  m_httpSaveAppointment = new MyHTTPService()
                  m_httpSaveAppointment.url="./php/db_updateAppointment.php";
                  m_httpSaveAppointment.addEventListener("result", fSaveAppointmentConfirmed);
                  m_httpSaveAppointment.send(m_Appointment.toHTTPObject());
                  CursorManager.setBusyCursor();
                  ---------------
                  //result listener
                  private function fSaveAppointmentConfirmed(event:ResultEvent):void
                  {
                  CursorManager.removeBusyCursor();
                  m_httpSaveAppointment.removeEventListener("result", fSaveAppointmentConfirmed);

                  //appointment has been saved
                  var l_iResult:int = m_httpSaveAppointment.lastResult.appointment.id;
                  //process result

                  m_httpSaveAppointment.disconnect();
                  m_httpSaveAppointment = null;
                  }


                  PS My last step was disabling output_buffering in PHP.
                  Don't know about the result yet, as it works in production environment only for 3 hours.

                  The connections happens over SSL. Client is using IE 7 browser. Also tried FF2.- same result.

                  I never had this problem in my test environment, but I am not working with the system for hours without interruption and test system is in the local network, no SSL, Apache/PHP versions are the same.


                  Thank you,

                  Dmitri.
                  • 6. Re: problems HTTPService
                    Mitek17 Level 1
                    Disabling the buffering didn't help neither.

                    Any other thoughts?

                    Thanks!

                    Dmitri.
                    • 7. Re: problems HTTPService
                      Mitek17 Level 1
                      G'day!

                      Here are the latest results from my HTTPService problem saga.

                      I isolated the problem to the Apache2.x/mod_ssl2.x and HTTPService configuration.

                      HTTPService works very stable with Apache 1.3/mod_ssl but with Apache2 SSL connection is vulnerable to network errors.

                      With full logging turned on everywhere(wireshark/apache/PIX firewall) I could see that sometimes due to the network errors connection gets into the state when both sides are doing nothing, waiting for each other and then one of the sides disconnects on time out.

                      Same network errors are not a problem for the browser itself or during the session with Apache1 - connection recovery happens very quickly and I have not got any timeout so far.

                      Cheers,
                      Dmitri.