-- Stefan Oestreicher <[EMAIL PROTECTED]> wrote
(on Wednesday, 16 July 2008, 02:02 PM +0200):
> I'm using Zend_Http_Client in several projects and I'm often getting an
> exception with the message "Unable to read response or response is empty"
> with no apparent reason. Currently I just retry the request if that
> exception occurs and it works fine. However, this is quite tedious and I
> never had any issue like this with other implementations.
> Is this a bug or am I missing something?
My experience is that these errors happen when there is a malformed
response -- which can happen due to a timeout when connecting to the
other server, a 500 error, etc -- typically, transitory issues, which is
why subsequent requests often work.
Tweaking some of the HTTP client configuration will sometimes help --
upping the timeout rate, etc. You could also try using a loop:
do {
$success = true;
try {
// do request...
} catch (Zend_Http_Client_Exception $e) {
$success = false;
}
} while (!$success);
Of course, you'll probably also want to add a counter to that loop to
ensure that if there is a long-standing connectivity issue, you don't go
into an infinite loop situation.
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend Framework | http://framework.zend.com/