Newbie delurks with HTTP:Request timeout problem.

From: Date: Thu, 18 Mar 2004 17:14:49 +0000
Subject: Newbie delurks with HTTP:Request timeout problem.
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11374@lists.php.net to get a copy of this message
Hi, Preamble: I'm a long-time C programmer, newly (i.e. only two years ago) converted to PHP and very recently I've started using the PEAR classes. The problem I've got here might be an Apache config problem, but even if it is, I'm wondering why the HTTP Request is blocking instead of returning. The problem: When using the PEAR (pear.php.net) HTTP Request class I'm getting a 15 second timeout before my call to sendRequest() returns. In more detail: We've got a Mandrake 9.1 base distro (kernel 2.4.21) with Apache 2.0.48, PHP 4.3.4, (and FWIW MySQL 3.23). Running on it we have a PHP / MySQL app. In order to test it, I've knocked up a separate PHP script that POSTs variables to the app (in order to mimic a user filling in forms etc) and writes the output to a file. The test script (we'll call it webproddle [tm] cos that's what I named it) uses the PEAR HTTP Request class to post the data to the application. Stripping the irrelevant crud out of my script we get: $method = "HTTP_REQUEST_METHOD_POST"; $hostname = "http://192.168.1.31"; $path = "/callback/run.php"; $req =& new HTTP_Request("$hostname"."$path"); $req->setMethod($method); $req->clearPostData(); // get some data to post here $req->addPostData($linebits[0], $linebits[1]); $reqreturn = $req->sendRequest(); It all runs quickly up to the sendRequest() call. By following (tail -f) the apache log file I see that the call is logged as completed (i.e. return code 200) perfectly quickly. And when the function does return and I read the response it is all fine. Delving into the sendRequest call() it gets stuck inside _readChunked() inside request.php at the point it calls _sock->readAll(). The comment for readAll() says "THIS FUNCTION WILL NOT EXIT if the socket is in blocking mode until the socket closes" - and it is (unsurprisingly) in blocking mode. It blocks on the read() inside readAll() for 15 seconds. So, err, does anyone have any experience of this Request class in PHP? Why is it in blocking mode? Any other tips?

« previous php.pear.general (#11374) next »