RE: connection: close header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Did some quick reading:
http://bugs.php.net/bug.php?id=9388&edit=1
  "Apache will keep a pconnection open no matter if it's a keep-alive
HTTP connection or not."
   also...
  "With phpinfo I get 'HTTP_CONNECTION=Keep-Alive'"  (in the
"Environment" section)

Maybe have the application hit a PHP script that records the
$_SERVER['HTTP_CONNECTION'] for you and make sure it says "Keep-Alive".
When I hit my PHP scripts, it returns a Keep-Alive, but maybe that's IE
telling IIS to create a persistent connection.   I get the same with
Opera.   I read that HTTP 1.1 goes persistent by default, but that HTTP
1.0 doesn't. Maybe the application is doing a 1.0 call and Apache
(which, as stated above, always does a persistent connection) and ASP
(which somehow forces persistent? Or maybe just doesn't properly close
the connection due to sloppiness on MS's part or something) manage to
keep it persistent anyway, but PHP triggers the Close, which would be
normal for HTTP 1.0 on IIS.

I was able to change the HTTP_CONNECTION environment variable with:
putenv("HTTP_CONNECTION=Keep-Alive");

Try the following code:

<?php
putenv("HTTP_CONNECTION=Keep-Alive");
phpinfo();
?>

Maybe make a test version of this and have your application hit the page
with and without the "putenv" and record the $getenv("HTTP_CONNECTION")
each time.

Maybe this will force it to be persistent.


Might be some info here too:
http://www.php-faq.com/httpconnections.php#8.1.2.1


Good luck!

-TG



> -----Original Message-----
> From: d c [mailto:php9341@xxxxxxxxx] 
> Sent: Friday, August 13, 2004 2:08 PM
> To: php-windows@xxxxxxxxxxxxx
> Subject: RE:  connection: close header
> 
> 
> The page is for uploading files. The client posts some info 
> about the file, and also the file itself. The file is 
> actually sent in chunks. The client is hitting the page 
> multiple times until all of the chunks for the file are 
> uploaded. All of the data is being sent the the php page, and 
> the first chunk/file info are stored in the db. Since the 
> client is trying to re-use the connection, the other chunks 
> are not getting sent. It is instead timing-out. Simulating 
> the client in a web browser will upload all of the chunks, 
> hitting the page multiple times. I don't know why the client 
> was written to try to use persistant connections. It doesn't 
> make sense to me to do it that way, but that's the way it is.
>  
> With the client, it works on Apache on Windows, but not with 
> IIS. The only difference between Apache and IIS is the 
> "Connection: close" header present from IIS. The only 
> difference with the asp page and the php page on IIS is the 
> "Connection: close" header also.
> 
> "Gryffyn, Trevor" <TGryffyn@xxxxxxxxxxxxxxxxx> wrote:
> Yeah, I understand that bit. Persistent connections to the web server
> make sense to me. What doesn't make sense is why you'd require a
> persisent connection for something to work. The workstation might be
> persistently connected to the web server, but a PHP, ASP or 
> HTML page is
> going to send it's data, then stop. Then you send another request to
> the web server and it sends more data to you. Then you make another
> request and it sends more data. Whether you're persistent or not
> shouldn't make something break as far as I know. It might 
> make things a
> little slower because of having to renegotiate the 
> connection, but since
> HTTP is connectionless by nature, the data it sends doesn't require
> persistent connection.
> 
> That's what sessions are for, isn't it?
> 
> Not trying to be antagonistic, I just don't understand why a 
> persistent
> connection is required for this to work. Maybe Dave is asking 
> the wrong
> question.
> 
> Ok, working with Dave's response to this where he says that he doesn't
> have the option of changing the client, let's focus on the 
> PHP page that
> the application is accessing.
> 
> Dave, describe "Not working correctly". What is the nature of the data
> the application sends to the PHP and ASP pages, why does it need a
> persistent connection (again, maybe this isn't the right question to
> solve this problem) and what's the PHP page doing that the 
> ASP doesn't.
> Is it not retrieving all the data or something?
> 
> A little more detail might help solve this one.
> 
> -TG
> 
> > -----Original Message-----
> > From: Justin Patrin [mailto:papercrane@xxxxxxxxx] 
> > Sent: Thursday, August 12, 2004 5:45 PM
> > To: Gryffyn, Trevor
> > Cc: php-windows@xxxxxxxxxxxxx; d c
> > Subject: Re:  connection: close header
> > 
> > 
> > On Thu, 12 Aug 2004 15:38:02 -0400, Gryffyn, Trevor
> > wrote:
> > > Just tossing out my 2cents.. Maybe there's a way or a 
> > reason, but HTTP
> > > connections are, by their nature, connectionless. They 
> > send the data
> > > and close the connection. I'm not sure why you'd want to keep a
> > > persistant connection to a specific page.
> > > 
> > > There are "Keep Alive" codes you can send that maintain a 
> > connection to
> > > the web server so you don't have to go through all the 
> > handshaking and
> > > stuff again (ok, I'm not using exact terms here, forgive me.. My
> > > networking is a bit rusty) but that doesn't keep you 
> connected to a
> > > single PHP or HTML or ASP page, just the server.
> > > 
> > > Sounds like everything's behaving just as it was designed 
> > to and you're
> > > trying to do something really odd. But maybe I'm just not 
> > getting what
> > > you're trying to do or something.
> > > 
> > 
> > Actually, this is something that's supported by the HTTP 
> protocol. You
> > use the same TCP connection (stream) for multiple requests to the
> > webserver. It is a bit strange, but it's supported.
> > 
> > Sounds like the OPs webserver isn't allowing the persistent
> > connections to go through. Maybe Apache needs to be configured
> > differently. Or PHP might be doing it. Or maybe the client 
> application
> > should be rewritten to not use persistent HTTP connections. ;-)
> > 
> > > Just what popped into my head when I read this.
> > > 
> > > -TG
> > > 
> > > 
> > > 
> > > > -----Original Message-----
> > > > From: d c [mailto:php9341@xxxxxxxxx]
> > > > Sent: Thursday, August 12, 2004 2:51 PM
> > > > To: php-windows@xxxxxxxxxxxxx
> > > > Subject:  connection: close header
> > > >
> > > >
> > > > Hello,
> > > >
> > > > I am using php 4.3.4 on windows 2000 with iis 5 and isapi. We
> > > > recently switched from asp to php. There is an application
> > > > that we have that hits one of the pages to send some info,
> > > > and it uses persistant connections. The php page was not
> > > > working correctly, and a trace using ethereal showed that the
> > > > difference was the "Connection: close" header being sent with
> > > > the php page, while the "Connection" header was not present
> > > > in the asp page's response. I tried using the latest version
> > > > of php, and the header is still being sent.
> > > >
> > > > Is there a way to get iis to not close the connection with php?
> > > >
> > > > Thanks,
> > > > Dave
> > > >
> > 
> > -- 
> > DB_DataObject_FormBuilder - The database at your fingertips
> > http://pear.php.net/package/DB_DataObject_FormBuilder
> > 
> > paperCrane --Justin Patrin--
> > 
> 
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 		
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Mail - 50x more storage than other providers!
> 

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux