Large File Not Being Sent To Client

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John C. Frickson

    Large File Not Being Sent To Client

    My company produces reports for our customers in PDF format. I have a
    php script that verifies login status and access rights, and sends
    the pdf to the client using readfile().

    This has worked fine until recently. One of our customers' reports
    is 10.6MB, and the customer never receives it and I can't get it
    either. I checked the Apache access_log, and it shows varying
    amounts of bytes being sent, but always close to 10MB.

    I tried changing the php script to do fopen(), fread(), echo,
    ob_flush() and flush(). After each flush, I write a message to a log
    file. The messages in the log file stop at 10MB, as if the php script
    is hung.

    Using a network monitor, I see the connection being established, the
    HTTP GET being sent, but no content coming back.

    PHP version is 5.1.2
    Apache is 2.2.3
    OS is SuSE Linux Enterprise Server 10.0 - 64bit

    Current test version looks like this:

    ini_set("output _buffering", "0");
    ini_set("implic it_flush", "1");
    ini_set("memory _limit", "100M");
    ini_set("max_ex ecution_time", "600");
    $lth = 0;
    $in = fopen($path, "r");
    while (!feof($in)) {
    $data = fread($in, 8192);
    $lth += strlen($data);
    $errLog->WriteLog("Re ad $lth bytes" , "debug.txt" );
    echo $data;
    $errLog->WriteLog("Afte r echo" , "debug.txt" );
    ob_flush();
    $errLog->WriteLog("Afte r ob_flush" , "debug.txt" );
    flush();
    $errLog->WriteLog("Afte r flush" , "debug.txt" );
    }
    $errLog->WriteLog("Go t EOF", "debug.txt" );
    fclose($in);
    $errLog->WriteLog("En d of Script - read $lth bytes", "debug.txt" );


    The last five lines of the debug.txt log file say:

    Read 10223616 bytes
    After echo
    After ob_flush
    After flush
    Read 10231808 bytes
    After echo

    So it's never returning from the ob_flush() call. Time from first
    log entry to last is about 1 second.

    Any ideas?
    John
  • John C. Frickson

    #2
    Re: Large File Not Being Sent To Client

    On 2007-03-09 10:28, John C. Frickson wrote:
    My company produces reports for our customers in PDF format. I have a
    php script that verifies login status and access rights, and sends
    the pdf to the client using readfile().
    >
    This has worked fine until recently. One of our customers' reports
    is 10.6MB, and the customer never receives it and I can't get it
    either. I checked the Apache access_log, and it shows varying
    amounts of bytes being sent, but always close to 10MB.
    >
    I tried changing the php script to do fopen(), fread(), echo,
    ob_flush() and flush(). After each flush, I write a message to a log
    file. The messages in the log file stop at 10MB, as if the php script
    is hung.
    >
    Using a network monitor, I see the connection being established, the
    HTTP GET being sent, but no content coming back.
    >
    PHP version is 5.1.2
    Apache is 2.2.3
    OS is SuSE Linux Enterprise Server 10.0 - 64bit
    >
    Current test version looks like this:
    >
    ini_set("output _buffering", "0");
    ini_set("implic it_flush", "1");
    ini_set("memory _limit", "100M");
    ini_set("max_ex ecution_time", "600");
    $lth = 0;
    $in = fopen($path, "r");
    while (!feof($in)) {
    $data = fread($in, 8192);
    $lth += strlen($data);
    $errLog->WriteLog("Re ad $lth bytes" , "debug.txt" );
    echo $data;
    $errLog->WriteLog("Afte r echo" , "debug.txt" );
    ob_flush();
    $errLog->WriteLog("Afte r ob_flush" , "debug.txt" );
    flush();
    $errLog->WriteLog("Afte r flush" , "debug.txt" );
    }
    $errLog->WriteLog("Go t EOF", "debug.txt" );
    fclose($in);
    $errLog->WriteLog("En d of Script - read $lth bytes", "debug.txt" );
    >
    >
    The last five lines of the debug.txt log file say:
    >
    Read 10223616 bytes
    After echo
    After ob_flush
    After flush
    Read 10231808 bytes
    After echo
    >
    So it's never returning from the ob_flush() call. Time from first
    log entry to last is about 1 second.
    >
    Any ideas?
    John
    I noticed I didn't have a "Content-Length" header, so I added it
    and it's now working. Even without the header, it should have
    worked anyway, shouldn't it?

    Comment

    • Jerry Stuckle

      #3
      Re: Large File Not Being Sent To Client

      John C. Frickson wrote:
      On 2007-03-09 10:28, John C. Frickson wrote:
      >My company produces reports for our customers in PDF format. I have a
      >php script that verifies login status and access rights, and sends
      >the pdf to the client using readfile().
      >>
      >This has worked fine until recently. One of our customers' reports
      >is 10.6MB, and the customer never receives it and I can't get it
      >either. I checked the Apache access_log, and it shows varying
      >amounts of bytes being sent, but always close to 10MB.
      >>
      >I tried changing the php script to do fopen(), fread(), echo,
      >ob_flush() and flush(). After each flush, I write a message to a log
      >file. The messages in the log file stop at 10MB, as if the php script
      >is hung.
      >>
      >Using a network monitor, I see the connection being established, the
      >HTTP GET being sent, but no content coming back.
      >>
      >PHP version is 5.1.2
      >Apache is 2.2.3
      >OS is SuSE Linux Enterprise Server 10.0 - 64bit
      >>
      >Current test version looks like this:
      >>
      > ini_set("output _buffering", "0");
      > ini_set("implic it_flush", "1");
      > ini_set("memory _limit", "100M");
      > ini_set("max_ex ecution_time", "600");
      > $lth = 0;
      > $in = fopen($path, "r");
      > while (!feof($in)) {
      > $data = fread($in, 8192);
      > $lth += strlen($data);
      > $errLog->WriteLog("Re ad $lth bytes" , "debug.txt" );
      > echo $data;
      > $errLog->WriteLog("Afte r echo" , "debug.txt" );
      > ob_flush();
      > $errLog->WriteLog("Afte r ob_flush" , "debug.txt" );
      > flush();
      > $errLog->WriteLog("Afte r flush" , "debug.txt" );
      > }
      > $errLog->WriteLog("Go t EOF", "debug.txt" );
      > fclose($in);
      > $errLog->WriteLog("En d of Script - read $lth bytes", "debug.txt" );
      >>
      >>
      >The last five lines of the debug.txt log file say:
      >>
      > Read 10223616 bytes
      > After echo
      > After ob_flush
      > After flush
      > Read 10231808 bytes
      > After echo
      >>
      >So it's never returning from the ob_flush() call. Time from first
      >log entry to last is about 1 second.
      >>
      >Any ideas?
      >John
      >
      I noticed I didn't have a "Content-Length" header, so I added it
      and it's now working. Even without the header, it should have
      worked anyway, shouldn't it?
      Not reliably. There is a reason for the Content-Length header - to let
      the browser know how much to expect.

      Without the header the browser is free to figure on it's own how long
      the data should be (no browser I know of allows "unlimited length). And
      evidently you finally exceeded the browser default.


      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • John C. Frickson

        #4
        Re: Large File Not Being Sent To Client



        On 2007-03-09 20:41, Jerry Stuckle wrote:
        John C. Frickson wrote:
        >On 2007-03-09 10:28, John C. Frickson wrote:
        >>My company produces reports for our customers in PDF format. I have a
        >>php script that verifies login status and access rights, and sends
        >>the pdf to the client using readfile().
        >>>
        >>This has worked fine until recently. One of our customers' reports
        >>is 10.6MB, and the customer never receives it and I can't get it
        >>either. I checked the Apache access_log, and it shows varying
        >>amounts of bytes being sent, but always close to 10MB.
        >>>
        >>I tried changing the php script to do fopen(), fread(), echo,
        >>ob_flush() and flush(). After each flush, I write a message to a log
        >>file. The messages in the log file stop at 10MB, as if the php script
        >>is hung.
        >>>
        >>Using a network monitor, I see the connection being established, the
        >>HTTP GET being sent, but no content coming back.
        >>>
        >>PHP version is 5.1.2
        >>Apache is 2.2.3
        >>OS is SuSE Linux Enterprise Server 10.0 - 64bit
        >>>
        >>Current test version looks like this:
        >>>
        >> ini_set("output _buffering", "0");
        >> ini_set("implic it_flush", "1");
        >> ini_set("memory _limit", "100M");
        >> ini_set("max_ex ecution_time", "600");
        >> $lth = 0;
        >> $in = fopen($path, "r");
        >> while (!feof($in)) {
        >> $data = fread($in, 8192);
        >> $lth += strlen($data);
        >> $errLog->WriteLog("Re ad $lth bytes" , "debug.txt" );
        >> echo $data;
        >> $errLog->WriteLog("Afte r echo" , "debug.txt" );
        >> ob_flush();
        >> $errLog->WriteLog("Afte r ob_flush" , "debug.txt" );
        >> flush();
        >> $errLog->WriteLog("Afte r flush" , "debug.txt" );
        >> }
        >> $errLog->WriteLog("Go t EOF", "debug.txt" );
        >> fclose($in);
        >> $errLog->WriteLog("En d of Script - read $lth bytes", "debug.txt" );
        >>>
        >>>
        >>The last five lines of the debug.txt log file say:
        >>>
        >> Read 10223616 bytes
        >> After echo
        >> After ob_flush
        >> After flush
        >> Read 10231808 bytes
        >> After echo
        >>>
        >>So it's never returning from the ob_flush() call. Time from first
        >>log entry to last is about 1 second.
        >>>
        >>Any ideas?
        >>John
        >>
        >I noticed I didn't have a "Content-Length" header, so I added it
        >and it's now working. Even without the header, it should have
        >worked anyway, shouldn't it?
        >
        Not reliably. There is a reason for the Content-Length header - to let
        the browser know how much to expect.
        >
        Without the header the browser is free to figure on it's own how long
        the data should be (no browser I know of allows "unlimited length). And
        evidently you finally exceeded the browser default.
        >
        Except NO data ever got sent to the browser. So it's something in
        either PHP or Apache that decided to quit. True, I wrote bad code
        by forgetting the Content-Length header, but it's a bit disturbing
        that PHP or Apache just didn't send any data without any kind of
        warning or error message.

        Comment

        • Jerry Stuckle

          #5
          Re: Large File Not Being Sent To Client

          John C. Frickson wrote:
          >
          >
          On 2007-03-09 20:41, Jerry Stuckle wrote:
          >John C. Frickson wrote:
          >>On 2007-03-09 10:28, John C. Frickson wrote:
          >>>My company produces reports for our customers in PDF format. I have a
          >>>php script that verifies login status and access rights, and sends
          >>>the pdf to the client using readfile().
          >>>>
          >>>This has worked fine until recently. One of our customers' reports
          >>>is 10.6MB, and the customer never receives it and I can't get it
          >>>either. I checked the Apache access_log, and it shows varying
          >>>amounts of bytes being sent, but always close to 10MB.
          >>>>
          >>>I tried changing the php script to do fopen(), fread(), echo,
          >>>ob_flush() and flush(). After each flush, I write a message to a log
          >>>file. The messages in the log file stop at 10MB, as if the php script
          >>>is hung.
          >>>>
          >>>Using a network monitor, I see the connection being established, the
          >>>HTTP GET being sent, but no content coming back.
          >>>>
          >>>PHP version is 5.1.2
          >>>Apache is 2.2.3
          >>>OS is SuSE Linux Enterprise Server 10.0 - 64bit
          >>>>
          >>>Current test version looks like this:
          >>>>
          >>> ini_set("output _buffering", "0");
          >>> ini_set("implic it_flush", "1");
          >>> ini_set("memory _limit", "100M");
          >>> ini_set("max_ex ecution_time", "600");
          >>> $lth = 0;
          >>> $in = fopen($path, "r");
          >>> while (!feof($in)) {
          >>> $data = fread($in, 8192);
          >>> $lth += strlen($data);
          >>> $errLog->WriteLog("Re ad $lth bytes" , "debug.txt" );
          >>> echo $data;
          >>> $errLog->WriteLog("Afte r echo" , "debug.txt" );
          >>> ob_flush();
          >>> $errLog->WriteLog("Afte r ob_flush" , "debug.txt" );
          >>> flush();
          >>> $errLog->WriteLog("Afte r flush" , "debug.txt" );
          >>> }
          >>> $errLog->WriteLog("Go t EOF", "debug.txt" );
          >>> fclose($in);
          >>> $errLog->WriteLog("En d of Script - read $lth bytes", "debug.txt" );
          >>>>
          >>>>
          >>>The last five lines of the debug.txt log file say:
          >>>>
          >>> Read 10223616 bytes
          >>> After echo
          >>> After ob_flush
          >>> After flush
          >>> Read 10231808 bytes
          >>> After echo
          >>>>
          >>>So it's never returning from the ob_flush() call. Time from first
          >>>log entry to last is about 1 second.
          >>>>
          >>>Any ideas?
          >>>John
          >>>
          >>I noticed I didn't have a "Content-Length" header, so I added it
          >>and it's now working. Even without the header, it should have
          >>worked anyway, shouldn't it?
          >>
          >Not reliably. There is a reason for the Content-Length header - to
          >let the browser know how much to expect.
          >>
          >Without the header the browser is free to figure on it's own how long
          >the data should be (no browser I know of allows "unlimited length).
          >And evidently you finally exceeded the browser default.
          >>
          >
          Except NO data ever got sent to the browser. So it's something in
          either PHP or Apache that decided to quit. True, I wrote bad code
          by forgetting the Content-Length header, but it's a bit disturbing
          that PHP or Apache just didn't send any data without any kind of
          warning or error message.
          What's in your Apache error log?

          Or, if you are logging PHP errors to a separate log file (unusual, but
          possible - check phpinfo()), what's in it?

          And if there is such a severe error that PHP/Apache can't send your data
          to the browser, it probably can't send an error message, either. But it
          will log something.


          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • John C. Frickson

            #6
            Re: Large File Not Being Sent To Client



            On 2007-03-11 07:48, Jerry Stuckle wrote:
            John C. Frickson wrote:
            >>
            >>
            >On 2007-03-09 20:41, Jerry Stuckle wrote:
            >>John C. Frickson wrote:
            >>>On 2007-03-09 10:28, John C. Frickson wrote:
            >>>>My company produces reports for our customers in PDF format. I have a
            >>>>php script that verifies login status and access rights, and sends
            >>>>the pdf to the client using readfile().
            >>>>>
            >>>>This has worked fine until recently. One of our customers' reports
            >>>>is 10.6MB, and the customer never receives it and I can't get it
            >>>>either. I checked the Apache access_log, and it shows varying
            >>>>amounts of bytes being sent, but always close to 10MB.
            >>>>>
            >>>>I tried changing the php script to do fopen(), fread(), echo,
            >>>>ob_flush( ) and flush(). After each flush, I write a message to a log
            >>>>file. The messages in the log file stop at 10MB, as if the php script
            >>>>is hung.
            >>>>>
            >>>>Using a network monitor, I see the connection being established, the
            >>>>HTTP GET being sent, but no content coming back.
            >>>>>
            >>>>PHP version is 5.1.2
            >>>>Apache is 2.2.3
            >>>>OS is SuSE Linux Enterprise Server 10.0 - 64bit
            >>>>>
            >>>>Current test version looks like this:
            >>>>>
            >>>> ini_set("output _buffering", "0");
            >>>> ini_set("implic it_flush", "1");
            >>>> ini_set("memory _limit", "100M");
            >>>> ini_set("max_ex ecution_time", "600");
            >>>> $lth = 0;
            >>>> $in = fopen($path, "r");
            >>>> while (!feof($in)) {
            >>>> $data = fread($in, 8192);
            >>>> $lth += strlen($data);
            >>>> $errLog->WriteLog("Re ad $lth bytes" , "debug.txt" );
            >>>> echo $data;
            >>>> $errLog->WriteLog("Afte r echo" , "debug.txt" );
            >>>> ob_flush();
            >>>> $errLog->WriteLog("Afte r ob_flush" , "debug.txt" );
            >>>> flush();
            >>>> $errLog->WriteLog("Afte r flush" , "debug.txt" );
            >>>> }
            >>>> $errLog->WriteLog("Go t EOF", "debug.txt" );
            >>>> fclose($in);
            >>>> $errLog->WriteLog("En d of Script - read $lth bytes", "debug.txt" );
            >>>>>
            >>>>>
            >>>>The last five lines of the debug.txt log file say:
            >>>>>
            >>>> Read 10223616 bytes
            >>>> After echo
            >>>> After ob_flush
            >>>> After flush
            >>>> Read 10231808 bytes
            >>>> After echo
            >>>>>
            >>>>So it's never returning from the ob_flush() call. Time from first
            >>>>log entry to last is about 1 second.
            >>>>>
            >>>>Any ideas?
            >>>>John
            >>>>
            >>>I noticed I didn't have a "Content-Length" header, so I added it
            >>>and it's now working. Even without the header, it should have
            >>>worked anyway, shouldn't it?
            >>>
            >>Not reliably. There is a reason for the Content-Length header - to
            >>let the browser know how much to expect.
            >>>
            >>Without the header the browser is free to figure on it's own how long
            >>the data should be (no browser I know of allows "unlimited length).
            >>And evidently you finally exceeded the browser default.
            >>>
            >>
            >Except NO data ever got sent to the browser. So it's something in
            >either PHP or Apache that decided to quit. True, I wrote bad code
            >by forgetting the Content-Length header, but it's a bit disturbing
            >that PHP or Apache just didn't send any data without any kind of
            >warning or error message.
            >
            What's in your Apache error log?
            >
            Or, if you are logging PHP errors to a separate log file (unusual, but
            possible - check phpinfo()), what's in it?
            >
            And if there is such a severe error that PHP/Apache can't send your data
            to the browser, it probably can't send an error message, either. But it
            will log something.
            >
            Nothing in the Apache error log (where PHP errors usually go).
            The Apache access log shows a "200" response code and a short
            number of bytes (such as 10343101 when it should be 11500016).

            I'm cross-posting this to a couple other groups that might be
            relevant.

            Comment

            • Jerry Stuckle

              #7
              Re: Large File Not Being Sent To Client

              John C. Frickson wrote:
              >
              >
              On 2007-03-11 07:48, Jerry Stuckle wrote:
              >John C. Frickson wrote:
              >>>
              >>>
              >>On 2007-03-09 20:41, Jerry Stuckle wrote:
              >>>John C. Frickson wrote:
              >>>>On 2007-03-09 10:28, John C. Frickson wrote:
              >>>>>My company produces reports for our customers in PDF format. I have a
              >>>>>php script that verifies login status and access rights, and sends
              >>>>>the pdf to the client using readfile().
              >>>>>>
              >>>>>This has worked fine until recently. One of our customers' reports
              >>>>>is 10.6MB, and the customer never receives it and I can't get it
              >>>>>either. I checked the Apache access_log, and it shows varying
              >>>>>amounts of bytes being sent, but always close to 10MB.
              >>>>>>
              >>>>>I tried changing the php script to do fopen(), fread(), echo,
              >>>>>ob_flush () and flush(). After each flush, I write a message to a log
              >>>>>file. The messages in the log file stop at 10MB, as if the php script
              >>>>>is hung.
              >>>>>>
              >>>>>Using a network monitor, I see the connection being established, the
              >>>>>HTTP GET being sent, but no content coming back.
              >>>>>>
              >>>>>PHP version is 5.1.2
              >>>>>Apache is 2.2.3
              >>>>>OS is SuSE Linux Enterprise Server 10.0 - 64bit
              >>>>>>
              >>>>>Current test version looks like this:
              >>>>>>
              >>>>> ini_set("output _buffering", "0");
              >>>>> ini_set("implic it_flush", "1");
              >>>>> ini_set("memory _limit", "100M");
              >>>>> ini_set("max_ex ecution_time", "600");
              >>>>> $lth = 0;
              >>>>> $in = fopen($path, "r");
              >>>>> while (!feof($in)) {
              >>>>> $data = fread($in, 8192);
              >>>>> $lth += strlen($data);
              >>>>> $errLog->WriteLog("Re ad $lth bytes" , "debug.txt" );
              >>>>> echo $data;
              >>>>> $errLog->WriteLog("Afte r echo" , "debug.txt" );
              >>>>> ob_flush();
              >>>>> $errLog->WriteLog("Afte r ob_flush" , "debug.txt" );
              >>>>> flush();
              >>>>> $errLog->WriteLog("Afte r flush" , "debug.txt" );
              >>>>> }
              >>>>> $errLog->WriteLog("Go t EOF", "debug.txt" );
              >>>>> fclose($in);
              >>>>> $errLog->WriteLog("En d of Script - read $lth bytes", "debug.txt" );
              >>>>>>
              >>>>>>
              >>>>>The last five lines of the debug.txt log file say:
              >>>>>>
              >>>>> Read 10223616 bytes
              >>>>> After echo
              >>>>> After ob_flush
              >>>>> After flush
              >>>>> Read 10231808 bytes
              >>>>> After echo
              >>>>>>
              >>>>>So it's never returning from the ob_flush() call. Time from first
              >>>>>log entry to last is about 1 second.
              >>>>>>
              >>>>>Any ideas?
              >>>>>John
              >>>>>
              >>>>I noticed I didn't have a "Content-Length" header, so I added it
              >>>>and it's now working. Even without the header, it should have
              >>>>worked anyway, shouldn't it?
              >>>>
              >>>Not reliably. There is a reason for the Content-Length header - to
              >>>let the browser know how much to expect.
              >>>>
              >>>Without the header the browser is free to figure on it's own how
              >>>long the data should be (no browser I know of allows "unlimited
              >>>length). And evidently you finally exceeded the browser default.
              >>>>
              >>>
              >>Except NO data ever got sent to the browser. So it's something in
              >>either PHP or Apache that decided to quit. True, I wrote bad code
              >>by forgetting the Content-Length header, but it's a bit disturbing
              >>that PHP or Apache just didn't send any data without any kind of
              >>warning or error message.
              >>
              >What's in your Apache error log?
              >>
              >Or, if you are logging PHP errors to a separate log file (unusual, but
              >possible - check phpinfo()), what's in it?
              >>
              >And if there is such a severe error that PHP/Apache can't send your
              >data to the browser, it probably can't send an error message, either.
              >But it will log something.
              >>
              >
              Nothing in the Apache error log (where PHP errors usually go).
              The Apache access log shows a "200" response code and a short
              number of bytes (such as 10343101 when it should be 11500016).
              >
              I'm cross-posting this to a couple other groups that might be
              relevant.
              In that case data WAS sent to the browser. But since it was incomplete
              it looks like the browser just didn't display anything.

              That's not unusual.

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              • shimmyshack

                #8
                Re: Large File Not Being Sent To Client

                On 11 Mar, 18:11, "John C. Frickson" <frickson_AT_gi bbon.comwrote:
                On 2007-03-11 07:48, Jerry Stuckle wrote:
                >
                >
                >
                John C. Frickson wrote:
                >
                On 2007-03-09 20:41, Jerry Stuckle wrote:
                >John C. Frickson wrote:
                >>On 2007-03-09 10:28, John C. Frickson wrote:
                >>>My company produces reports for our customers in PDF format. I have a
                >>>php script that verifies login status and access rights, and sends
                >>>the pdf to the client using readfile().
                >
                >>>This has worked fine until recently. One of our customers' reports
                >>>is 10.6MB, and the customer never receives it and I can't get it
                >>>either. I checked the Apache access_log, and it shows varying
                >>>amounts of bytes being sent, but always close to 10MB.
                >
                >>>I tried changing the php script to do fopen(), fread(), echo,
                >>>ob_flush() and flush(). After each flush, I write a message to a log
                >>>file. The messages in the log file stop at 10MB, as if the php script
                >>>is hung.
                >
                >>>Using a network monitor, I see the connection being established, the
                >>>HTTP GET being sent, but no content coming back.
                >
                >>>PHP version is 5.1.2
                >>>Apache is 2.2.3
                >>>OS is SuSE Linux Enterprise Server 10.0 - 64bit
                >
                >>>Current test version looks like this:
                >
                >>> ini_set("output _buffering", "0");
                >>> ini_set("implic it_flush", "1");
                >>> ini_set("memory _limit", "100M");
                >>> ini_set("max_ex ecution_time", "600");
                >>> $lth = 0;
                >>> $in = fopen($path, "r");
                >>> while (!feof($in)) {
                >>> $data = fread($in, 8192);
                >>> $lth += strlen($data);
                >>> $errLog->WriteLog("Re ad $lth bytes" , "debug.txt" );
                >>> echo $data;
                >>> $errLog->WriteLog("Afte r echo" , "debug.txt" );
                >>> ob_flush();
                >>> $errLog->WriteLog("Afte r ob_flush" , "debug.txt" );
                >>> flush();
                >>> $errLog->WriteLog("Afte r flush" , "debug.txt" );
                >>> }
                >>> $errLog->WriteLog("Go t EOF", "debug.txt" );
                >>> fclose($in);
                >>> $errLog->WriteLog("En d of Script - read $lth bytes", "debug.txt" );
                >
                >>>The last five lines of the debug.txt log file say:
                >
                >>> Read 10223616 bytes
                >>> After echo
                >>> After ob_flush
                >>> After flush
                >>> Read 10231808 bytes
                >>> After echo
                >
                >>>So it's never returning from the ob_flush() call. Time from first
                >>>log entry to last is about 1 second.
                >
                >>>Any ideas?
                >>>John
                >
                >>I noticed I didn't have a "Content-Length" header, so I added it
                >>and it's now working. Even without the header, it should have
                >>worked anyway, shouldn't it?
                >
                >Not reliably. There is a reason for the Content-Length header - to
                >let the browser know how much to expect.
                >
                >Without the header the browser is free to figure on it's own how long
                >the data should be (no browser I know of allows "unlimited length).
                >And evidently you finally exceeded the browser default.
                >
                Except NO data ever got sent to the browser. So it's something in
                either PHP or Apache that decided to quit. True, I wrote bad code
                by forgetting the Content-Length header, but it's a bit disturbing
                that PHP or Apache just didn't send any data without any kind of
                warning or error message.
                >
                What's in your Apache error log?
                >
                Or, if you are logging PHP errors to a separate log file (unusual, but
                possible - check phpinfo()), what's in it?
                >
                And if there is such a severe error that PHP/Apache can't send your data
                to the browser, it probably can't send an error message, either. But it
                will log something.
                >
                Nothing in the Apache error log (where PHP errors usually go).
                The Apache access log shows a "200" response code and a short
                number of bytes (such as 10343101 when it should be 11500016).
                >
                I'm cross-posting this to a couple other groups that might be
                relevant.
                resume.
                If in doubt put a static PDF served only by apache (not through
                script), and then GET that, stop it half way through and then refresh,
                watch the headers for status 206 and info about number of bytes offset/
                number of bytes content length.

                Comment

                • John C. Frickson

                  #9
                  Re: Large File Not Being Sent To Client



                  On 2007-03-11 13:34, Jerry Stuckle wrote:
                  John C. Frickson wrote:
                  >>
                  >>
                  >On 2007-03-11 07:48, Jerry Stuckle wrote:
                  >>John C. Frickson wrote:
                  >>>>
                  >>>>
                  >>>On 2007-03-09 20:41, Jerry Stuckle wrote:
                  >>>>John C. Frickson wrote:
                  >>>>>On 2007-03-09 10:28, John C. Frickson wrote:
                  >>>>>>My company produces reports for our customers in PDF format. I have a
                  >>>>>>php script that verifies login status and access rights, and sends
                  >>>>>>the pdf to the client using readfile().
                  >>>>>>>
                  >>>>>>This has worked fine until recently. One of our customers' reports
                  >>>>>>is 10.6MB, and the customer never receives it and I can't get it
                  >>>>>>either. I checked the Apache access_log, and it shows varying
                  >>>>>>amounts of bytes being sent, but always close to 10MB.
                  >>>>>>>
                  >>>>>>I tried changing the php script to do fopen(), fread(), echo,
                  >>>>>>ob_flush( ) and flush(). After each flush, I write a message to a log
                  >>>>>>file. The messages in the log file stop at 10MB, as if the php script
                  >>>>>>is hung.
                  >>>>>>>
                  >>>>>>Using a network monitor, I see the connection being established, the
                  >>>>>>HTTP GET being sent, but no content coming back.
                  >>>>>>>
                  >>>>>>PHP version is 5.1.2
                  >>>>>>Apache is 2.2.3
                  >>>>>>OS is SuSE Linux Enterprise Server 10.0 - 64bit
                  >>>>>>>
                  >>>>>>Current test version looks like this:
                  >>>>>>>
                  >>>>>> ini_set("output _buffering", "0");
                  >>>>>> ini_set("implic it_flush", "1");
                  >>>>>> ini_set("memory _limit", "100M");
                  >>>>>> ini_set("max_ex ecution_time", "600");
                  >>>>>> $lth = 0;
                  >>>>>> $in = fopen($path, "r");
                  >>>>>> while (!feof($in)) {
                  >>>>>> $data = fread($in, 8192);
                  >>>>>> $lth += strlen($data);
                  >>>>>> $errLog->WriteLog("Re ad $lth bytes" , "debug.txt" );
                  >>>>>> echo $data;
                  >>>>>> $errLog->WriteLog("Afte r echo" , "debug.txt" );
                  >>>>>> ob_flush();
                  >>>>>> $errLog->WriteLog("Afte r ob_flush" , "debug.txt" );
                  >>>>>> flush();
                  >>>>>> $errLog->WriteLog("Afte r flush" , "debug.txt" );
                  >>>>>> }
                  >>>>>> $errLog->WriteLog("Go t EOF", "debug.txt" );
                  >>>>>> fclose($in);
                  >>>>>> $errLog->WriteLog("En d of Script - read $lth bytes", "debug.txt" );
                  >>>>>>>
                  >>>>>>>
                  >>>>>>The last five lines of the debug.txt log file say:
                  >>>>>>>
                  >>>>>> Read 10223616 bytes
                  >>>>>> After echo
                  >>>>>> After ob_flush
                  >>>>>> After flush
                  >>>>>> Read 10231808 bytes
                  >>>>>> After echo
                  >>>>>>>
                  >>>>>>So it's never returning from the ob_flush() call. Time from first
                  >>>>>>log entry to last is about 1 second.
                  >>>>>>>
                  >>>>>>Any ideas?
                  >>>>>>John
                  >>>>>>
                  >>>>>I noticed I didn't have a "Content-Length" header, so I added it
                  >>>>>and it's now working. Even without the header, it should have
                  >>>>>worked anyway, shouldn't it?
                  >>>>>
                  >>>>Not reliably. There is a reason for the Content-Length header - to
                  >>>>let the browser know how much to expect.
                  >>>>>
                  >>>>Without the header the browser is free to figure on it's own how
                  >>>>long the data should be (no browser I know of allows "unlimited
                  >>>>length). And evidently you finally exceeded the browser default.
                  >>>>>
                  >>>>
                  >>>Except NO data ever got sent to the browser. So it's something in
                  >>>either PHP or Apache that decided to quit. True, I wrote bad code
                  >>>by forgetting the Content-Length header, but it's a bit disturbing
                  >>>that PHP or Apache just didn't send any data without any kind of
                  >>>warning or error message.
                  >>>
                  >>What's in your Apache error log?
                  >>>
                  >>Or, if you are logging PHP errors to a separate log file (unusual, but
                  >>possible - check phpinfo()), what's in it?
                  >>>
                  >>And if there is such a severe error that PHP/Apache can't send your
                  >>data to the browser, it probably can't send an error message, either.
                  >>But it will log something.
                  >>>
                  >>
                  >Nothing in the Apache error log (where PHP errors usually go).
                  >The Apache access log shows a "200" response code and a short
                  >number of bytes (such as 10343101 when it should be 11500016).
                  >>
                  >I'm cross-posting this to a couple other groups that might be
                  >relevant.
                  >
                  In that case data WAS sent to the browser. But since it was incomplete
                  it looks like the browser just didn't display anything.
                  >
                  That's not unusual.
                  In my original message I wrote "Using a network monitor, I see
                  the connection being established, the HTTP GET being sent, but
                  no content coming back." The browser did NOT receive ANY data.

                  Comment

                  • Jerry Stuckle

                    #10
                    Re: Large File Not Being Sent To Client

                    John C. Frickson wrote:
                    >
                    >
                    On 2007-03-11 13:34, Jerry Stuckle wrote:
                    >John C. Frickson wrote:
                    >>>
                    >>>
                    >>On 2007-03-11 07:48, Jerry Stuckle wrote:
                    >>>John C. Frickson wrote:
                    >>>>>
                    >>>>>
                    >>>>On 2007-03-09 20:41, Jerry Stuckle wrote:
                    >>>>>John C. Frickson wrote:
                    >>>>>>On 2007-03-09 10:28, John C. Frickson wrote:
                    >>>>>>>My company produces reports for our customers in PDF format. I
                    >>>>>>>have a
                    >>>>>>>php script that verifies login status and access rights, and sends
                    >>>>>>>the pdf to the client using readfile().
                    >>>>>>>>
                    >>>>>>>This has worked fine until recently. One of our customers' reports
                    >>>>>>>is 10.6MB, and the customer never receives it and I can't get it
                    >>>>>>>either . I checked the Apache access_log, and it shows varying
                    >>>>>>>amount s of bytes being sent, but always close to 10MB.
                    >>>>>>>>
                    >>>>>>>I tried changing the php script to do fopen(), fread(), echo,
                    >>>>>>>ob_flush () and flush(). After each flush, I write a message to a
                    >>>>>>>log
                    >>>>>>>file. The messages in the log file stop at 10MB, as if the php
                    >>>>>>>script
                    >>>>>>>is hung.
                    >>>>>>>>
                    >>>>>>>Using a network monitor, I see the connection being established,
                    >>>>>>>the
                    >>>>>>>HTTP GET being sent, but no content coming back.
                    >>>>>>>>
                    >>>>>>>PHP version is 5.1.2
                    >>>>>>>Apache is 2.2.3
                    >>>>>>>OS is SuSE Linux Enterprise Server 10.0 - 64bit
                    >>>>>>>>
                    >>>>>>>Curren t test version looks like this:
                    >>>>>>>>
                    >>>>>>> ini_set("output _buffering", "0");
                    >>>>>>> ini_set("implic it_flush", "1");
                    >>>>>>> ini_set("memory _limit", "100M");
                    >>>>>>> ini_set("max_ex ecution_time", "600");
                    >>>>>>> $lth = 0;
                    >>>>>>> $in = fopen($path, "r");
                    >>>>>>> while (!feof($in)) {
                    >>>>>>> $data = fread($in, 8192);
                    >>>>>>> $lth += strlen($data);
                    >>>>>>> $errLog->WriteLog("Re ad $lth bytes" , "debug.txt" );
                    >>>>>>> echo $data;
                    >>>>>>> $errLog->WriteLog("Afte r echo" , "debug.txt" );
                    >>>>>>> ob_flush();
                    >>>>>>> $errLog->WriteLog("Afte r ob_flush" , "debug.txt" );
                    >>>>>>> flush();
                    >>>>>>> $errLog->WriteLog("Afte r flush" , "debug.txt" );
                    >>>>>>> }
                    >>>>>>> $errLog->WriteLog("Go t EOF", "debug.txt" );
                    >>>>>>> fclose($in);
                    >>>>>>> $errLog->WriteLog("En d of Script - read $lth bytes",
                    >>>>>>>"debug.t xt");
                    >>>>>>>>
                    >>>>>>>>
                    >>>>>>>The last five lines of the debug.txt log file say:
                    >>>>>>>>
                    >>>>>>> Read 10223616 bytes
                    >>>>>>> After echo
                    >>>>>>> After ob_flush
                    >>>>>>> After flush
                    >>>>>>> Read 10231808 bytes
                    >>>>>>> After echo
                    >>>>>>>>
                    >>>>>>>So it's never returning from the ob_flush() call. Time from first
                    >>>>>>>log entry to last is about 1 second.
                    >>>>>>>>
                    >>>>>>>Any ideas?
                    >>>>>>>John
                    >>>>>>>
                    >>>>>>I noticed I didn't have a "Content-Length" header, so I added it
                    >>>>>>and it's now working. Even without the header, it should have
                    >>>>>>worked anyway, shouldn't it?
                    >>>>>>
                    >>>>>Not reliably. There is a reason for the Content-Length header -
                    >>>>>to let the browser know how much to expect.
                    >>>>>>
                    >>>>>Without the header the browser is free to figure on it's own how
                    >>>>>long the data should be (no browser I know of allows "unlimited
                    >>>>>length). And evidently you finally exceeded the browser default.
                    >>>>>>
                    >>>>>
                    >>>>Except NO data ever got sent to the browser. So it's something in
                    >>>>either PHP or Apache that decided to quit. True, I wrote bad code
                    >>>>by forgetting the Content-Length header, but it's a bit disturbing
                    >>>>that PHP or Apache just didn't send any data without any kind of
                    >>>>warning or error message.
                    >>>>
                    >>>What's in your Apache error log?
                    >>>>
                    >>>Or, if you are logging PHP errors to a separate log file (unusual,
                    >>>but possible - check phpinfo()), what's in it?
                    >>>>
                    >>>And if there is such a severe error that PHP/Apache can't send your
                    >>>data to the browser, it probably can't send an error message,
                    >>>either. But it will log something.
                    >>>>
                    >>>
                    >>Nothing in the Apache error log (where PHP errors usually go).
                    >>The Apache access log shows a "200" response code and a short
                    >>number of bytes (such as 10343101 when it should be 11500016).
                    >>>
                    >>I'm cross-posting this to a couple other groups that might be
                    >>relevant.
                    >>
                    >In that case data WAS sent to the browser. But since it was
                    >incomplete it looks like the browser just didn't display anything.
                    >>
                    >That's not unusual.
                    >
                    In my original message I wrote "Using a network monitor, I see
                    the connection being established, the HTTP GET being sent, but
                    no content coming back." The browser did NOT receive ANY data.
                    And your Apache log says around 10M was sent. What happened to it?

                    --
                    =============== ===
                    Remove the "x" from my email address
                    Jerry Stuckle
                    JDS Computer Training Corp.
                    jstucklex@attgl obal.net
                    =============== ===

                    Comment

                    Working...