accounts.google.com:443的间歇性连接问题(与accounts.google.com:443相关的未知SSL协议错误)

时间:2017-12-07 09:11:34

标签: php curl google-analytics-api google-api-php-client

我正在尝试连接accounts.google.com:443以显示访问次数到应用程序。 低于错误

  

Google_IO_Exception:与Google.IO_Curl-> executeRequest()中的accounts.google.com:443相关的未知SSL协议错误(/ home / meme_dev / meme / meme-dev / sites / all / libraries / google-的第130行API-PHP-客户/ SRC /谷歌/ IO / Curl.php)。

但这是间歇性的。有时它有时不工作。 我们检查了服务器端没有防火墙/代理阻塞。

请帮助解决此问题

卷曲文件 - google-api-php-client / src / Google / IO / Curl.php

$curl = curl_init();

if ($request->getPostBody()) {
curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getPostBody());
}

$requestHeaders = $request->getRequestHeaders();
if ($requestHeaders && is_array($requestHeaders)) {
$curlHeaders = array();
foreach ($requestHeaders as $k => $v) {
$curlHeaders[] = "$k: $v";
}
curl_setopt($curl, CURLOPT_HTTPHEADER, $curlHeaders);
}
curl_setopt($curl, CURLOPT_URL, $request->getUrl());

curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request->getRequestMethod());
curl_setopt($curl, CURLOPT_USERAGENT, $request->getUserAgent());
$proxy = 'XX.XX.XX.XX:XXXX';    
curl_setopt($curl, CURLOPT_PROXY, $proxy);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);

// The SSL version will be determined by the underlying library
// @see https://github.com/google/google-api-php-client/pull/644
//curl_setopt($curl, CURLOPT_SSLVERSION, 1);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);


curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

if ($request->canGzip()) {
curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
}

$options = $this->client->getClassConfig('Google_IO_Curl', 'options');
if (is_array($options)) {
$this->setOptions($options);
}

foreach ($this->options as $key => $var) {
curl_setopt($curl, $key, $var);
}

if (!isset($this->options[CURLOPT_CAINFO])) {
curl_setopt($curl, CURLOPT_CAINFO, dirname(__FILE__) . '/cacerts.pem');
}

$this->client->getLogger()->debug(
'cURL request',
array(
'url' => $request->getUrl(),
'method' => $request->getRequestMethod(),
'headers' => $requestHeaders,
'body' => $request->getPostBody()
)
);
$response = curl_exec($curl);
watchdog('Curl response for GA', "GA response: @path", array("@path" => $response));
if ($response === false) {
$error = curl_error($curl);
$code = curl_errno($curl);
$map = $this->client->getClassConfig('Google_IO_Exception', 'retry_map');
watchdog('Curl error for GA', "GA response: @path", array("@path" => $error));
$this->client->getLogger()->error('cURL ' . $error);
throw new Google_IO_Exception($error, $code, null, $map);
}
$headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);

list($responseHeaders, $responseBody) = $this->parseHttpResponse($response, $headerSize);
$responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

$this->client->getLogger()->debug(
'cURL response',
array(
'code' => $responseCode,
'headers' => $responseHeaders,
'body' => $responseBody,
)
);

return array($responseBody, $responseHeaders, $responseCode);

0 个答案:

没有答案