[PHP] PHP timeout doing fread from Apache Coyote

2003-07-24 Thread Robert Fitzpatrick
I am trying to communicate with an API of a vendors of ours. They provide a
Perl example that works fast and well. I am trying to do the same thing with
a PHP class. The response takes over a minute before the response comes
back. I see from the response text that the API is running on Apache
Coyote/1.0. Does anyone know of issues with this match-up, here is the
snippet of code that seems to be hanging. Using my Komodo debugger, it
points to the line with 'while($data=fread($fp, 32768))' while waiting for
execution to continue. Using a Perl script provided by them, I get a
response in seconds. Basically, my PHP page prepares content and variables
and then uses this class to send XML formatted content to receive a
response.

  ...
  $fp=fsockopen($this-server, $this-port, $this-errno,
$this-errstr, $this-timeout);

  if(!$fp) {
$this-errstr=Cant Connect to Service ($this-server:$this-port,
$this-errno, $this-errstr);
return;
  }

  if (!fputs($fp, $op, strlen($op))) {
  $this-errstr=Write error;
  return;
  } else {

   $ipd = ;
   while($data=fread($fp, 32768)) {
  $ipd.=$data;
   }
$this-responsetext = $ipd;
//echo p.$ipd./p;
 $ipd = $this-_parse_header($ipd);

  }

  fclose($fp);
  return $ipd;
  ...



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



Re: [PHP] PHP timeout doing fread from Apache Coyote

2003-07-24 Thread Curt Zirzow
* Thus wrote Robert Fitzpatrick ([EMAIL PROTECTED]):
 I am trying to communicate with an API of a vendors of ours. They provide a
 Perl example that works fast and well. I am trying to do the same thing with
 a PHP class. The response takes over a minute before the response comes
 back. I see from the response text that the API is running on Apache
 Coyote/1.0. Does anyone know of issues with this match-up, here is the
 snippet of code that seems to be hanging. Using my Komodo debugger, it
 points to the line with 'while($data=fread($fp, 32768))' while waiting for
 execution to continue. Using a Perl script provided by them, I get a
 response in seconds. Basically, my PHP page prepares content and variables
 and then uses this class to send XML formatted content to receive a
 response.
 
   ...
   $fp=fsockopen($this-server, $this-port, $this-errno,
 $this-errstr, $this-timeout);
 
   if(!$fp) {
 $this-errstr=Cant Connect to Service ($this-server:$this-port,
 $this-errno, $this-errstr);
 return;
   }
 
   if (!fputs($fp, $op, strlen($op))) {

which HTTP version are you requesting?  I know that if you send a
HTTP/1.1 then a lot of servers send the data in chunks, thus your
retrieval code needs to be different. If it is HTTP/1.1 try using
HTTP/1.0 instead.


   $this-errstr=Write error;
   return;
   } else {
 
$ipd = ;
while($data=fread($fp, 32768)) {

Have you tried smaller requests mabey 512? although that shouldn't
matter, but you might be able to see if it is getting data back at
all.

   $ipd.=$data;
}

HTH,

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] PHP timeout doing fread from Apache Coyote

2003-07-24 Thread Robert Fitzpatrick
  if (!fputs($fp, $op, strlen($op))) {

 which HTTP version are you requesting? I know that if you send a
 HTTP/1.1 then a lot of servers send the data in chunks, thus your
 retrieval code needs to be different. If it is HTTP/1.1 try using
 HTTP/1.0 instead.

Same difference with the 1.0, I was using 1.1, here is the complete request
and response. The response comes back as 1.1 regardless of what I use (of
course, the xml parameter is urlencoded):

Request:
POST /XMLCommunicationServlet HTTP/1.0 Content-Type:
application/x-www-form-urlencoded User-Agent: PHP XMLRPC Host:
api.newedgenetworks.com:80 Connection: keep-alive Content-Length: 758
txnType=Ppartner=xml=%3C%3Fxml+version%3D%221.0%22%3F%3E%3C%21DOCTYPE+preq
ualrequest+SYSTEM+%22http%3A%2F%2Fapi.newedgenetworks.com%3A80%2Fdtd%2Fprequ
alrequest.dtd%22%3E%3CPrequalRequest%3E%3CIdentification%3E%3CUs
er%3Eusername%3C%2FUser%3E%3CPassword%3mypassword%3C%2FPassword%3E++
++%3C%2FIdentification%3E%3CServiceType%3ER%3C%2FServiceType%3E%3CAd
dress%3E+++%3CStreet1%3E2780+CEDARLINKS+DRIVE%3C%2FStreet1%3E+++%3CC
ity%3EMEDFORD%3C%2FCity%3E+++%3CState%3EOR%3C%2FState%3E+++%3CZipCD%
3E97504%3C%2FZipCD%3E%3C%2FAddress%3E%3CPhone%3E%3CPhoneNPA%
3E541%3C%2FPhoneNPA%3E%3CPhoneNXX%3E772%3C%2FPhoneNXX%3E%3CP
honeSuffix%3E6990%3C%2FPhoneSuffix%3E%3C%2FPhone%3E%3C%2FPrequalRequest%
3E

Response:
HTTP/1.1 200 OK Content-Type: text/xml Content-Length: 343 Date: Thu, 24 Jul
2003 15:18:52 GMT Server: Apache Coyote/1.0 Connection: Keep-Alive
1050Prequalification failed: AggregateCircuit unavailable

  $ipd = ;
  while($data=fread($fp, 32768)) {

 Have you tried smaller requests mabey 512? although that shouldn't
 matter, but you might be able to see if it is getting data back at
 all.

Yes, I've tried 128 and get the same delay.

Thanks for any help:)
--
Robert



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