Zend 超时重试

Zend Timeout Retry

长话短说,我被这个使用旧 zend 框架的旧 PHP 实用程序困住了。当它超时时我遇到了麻烦它不会重试所以它失败了。我已经完成了从更改超时计时器到更改最大重定向以及我可以对设置执行的所有其他操作,但仍然得到相同的结果。

我得到了一致的

Fatal error: Uncaught exception 'Zend_Http_Client_Exception' with message 'Unable to read response, or response is empty'

如果我碰巧尝试了足够多,它将毫无问题地工作。它只是重试这是问题。

我不确定应该将重试逻辑放在哪里。

我看到有人说它会在这里的某个地方 (Zend_http_client)

    public function request($method = null)
{
    if (! $this->uri instanceof Zend_Uri_Http) {
        /** @see Zend_Http_Client_Exception */
        require_once 'Zend/Http/Client/Exception.php';
        throw new Zend_Http_Client_Exception('No valid URI has been passed to the client');
    }

    if ($method) {
        $this->setMethod($method);
    }
    $this->redirectCounter = 0;
    $response = null;

    // Make sure the adapter is loaded
    if ($this->adapter == null) {
        $this->setAdapter($this->config['adapter']);
    }

    // Send the first request. If redirected, continue.
    do {
        // Clone the URI and add the additional GET parameters to it
        $uri = clone $this->uri;
        if (! empty($this->paramsGet)) {
            $query = $uri->getQuery();
               if (! empty($query)) {
                   $query .= '&';
               }
            $query .= http_build_query($this->paramsGet, null, '&');

            $uri->setQuery($query);
        }

        $body = $this->_prepareBody();
        $headers = $this->_prepareHeaders();

        // Open the connection, send the request and read the response
        $this->adapter->connect($uri->getHost(), $uri->getPort(),
            ($uri->getScheme() == 'https' ? true : false));

        $this->last_request = $this->adapter->write($this->method,
            $uri, $this->config['httpversion'], $headers, $body);

        $response = $this->adapter->read();
        if (! $response) {
            /** @see Zend_Http_Client_Exception */
            require_once 'Zend/Http/Client/Exception.php';
            throw new Zend_Http_Client_Exception('Unable to read response, or response is empty');
        }

        $response = Zend_Http_Response::fromString($response);
        if ($this->config['storeresponse']) {
            $this->last_response = $response;
        }

我在想它也可以放在这里(在我自己的代码中)

                $eventResponse = new Response($Client->Event(
                $theEvent,null));

                if (!$throwEventResponse->getResponseStatusOk()) {
                    $ex = new ResponseException("Unable to complete event.");
                    $ex->setErrorList($throwEventResponse->getErrorList());
                    throw $ex;
                }

我有点不知所措,我不确定如何着手才能最好地满足我的需要。

提前致谢!

发现通过将 HTTP 请求的类型从 HTML 1.1 更改为 1.0 解决了我在不等待上一个调用完成的情况下转移到下一个调用的问题。

在另一个请求完成之前推送第二个请求导致奇怪的缓存问题并且请求失败。