无法连接到www.googleapis.com端口443:网络无法访问 [英] Failed to connect to www.googleapis.com port 443: Network is unreachable

查看:1175
本文介绍了无法连接到www.googleapis.com端口443:网络无法访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此库从wordpress网站获取来自YouTube的视频和实时流的提要. https://github.com/google/google-api-php-client

I'm Using this library to get a feed of videos and livestreams from Youtube from a wordpress site. https://github.com/google/google-api-php-client

在过去的一个月中,该代码运行正常,但突然开始随机出现错误,无法连接错误(10次尝试中有2次失败,其他尝试都很好)

The code was working ok for the past month but suddenly it started to get Failed to connect errors randomly (2 in 10 attempts comes failed, the others goes just fine)

这是我从那里得到错误的代码:

This is the code from where im getting the error:

function googleapis_get_live_event_widget(){

    //Youtube Videos and Live Events
    require_once( get_stylesheet_directory() . '/lib/google-api-php-client/src/Google/autoload.php' );
    $GOOGLE_DEVELOPER_KEY = get_field('cce_api_google_developer_key','option');

    $client = new Google_Client();
    $client->setDeveloperKey($GOOGLE_DEVELOPER_KEY);
    $youtube = new Google_Service_YouTube($client);

    try {
        $islive = get_field('cce_live_event','option');

        $opts = array();
        $opts['channelId'] = get_field('cce_api_youtube_channel_id','option');
        if($islive) {
            $opts['eventType'] = 'live';
        }
        $opts['type'] = 'video';
        $opts['maxResults'] = 1;
        $opts['order'] = 'date';


        $live_videos = $youtube->search->listSearch('id,snippet',$opts);

        $data = array();
        $data['live_events'] = $live_videos;
        echo Timber::compile('partials/live_event_widget.twig',$data);

    } catch (Exception $e) {
        $error = array();
        $error['message'] = $e->getMessage();
        echo Timber::compile('partials/error.twig',$error);
        return;
    }


}

add_shortcode('googleapis_live_widget','googleapis_get_live_event_widget');

通过ssh在服务器中执行curl -v https://www.googleapis.com会导致以下尝试失败:

doing a curl -v https://www.googleapis.com via ssh in the server results in this when is a failed attempt:

[~]# curl -v https://www.googleapis.com
* About to connect() to www.googleapis.com port 443 (#0)
*   Trying 216.58.216.202... Connection timed out
*   Trying 2607:f8b0:4009:80b::200a... Failed to connect to     2607:f8b0:4009:80b::200a: Network is unreachable
* Success
* couldn't connect to host
* Closing connection #0
curl: (7) Failed to connect to 2607:f8b0:4009:80b::200a: Network is unreachable

当请求很好时,就像这样:

And like this when the request is good:

curl -v https://www.googleapis.com
* About to connect() to www.googleapis.com port 443 (#0)
*   Trying 216.58.216.106... connected
* Connected to www.googleapis.com (216.58.216.106) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_RSA_WITH_AES_128_CBC_SHA
* Server certificate:
*   subject: CN=*.googleapis.com,O=Google Inc,L=Mountain View,ST=California,C=US
*   start date: Oct 21 22:31:24 2015 GMT
*   expire date: Jan 19 00:00:00 2016 GMT
*   common name: *.googleapis.com
*   issuer: CN=Google Internet Authority G2,O=Google Inc,C=US
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: www.googleapis.com
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: Fri, 01 Jan 1990 00:00:00 GMT
< Date: Sat, 31 Oct 2015 11:33:49 GMT
< Vary: X-Origin
< Content-Type: text/html; charset=UTF-8
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< Server: GSE
< Alternate-Protocol: 443:quic,p=1
< Alt-Svc: quic=":443"; p="1"; ma=604800
< Accept-Ranges: none
< Vary: Origin,Accept-Encoding
< Transfer-Encoding: chunked
< 
* Connection #0 to host www.googleapis.com left intact
* Closing connection #0

此刻,如果我运行页面,则提要将正常显示.

At this moment if i run the page the feeds are displayed normally.

我应该如何解决不一致问题?

What should i be looking for fixing the inconsistency?

推荐答案

我遇到了相同的错误,并试图找出原因.

I've got the same error and trying to figure it out why.

此错误很可能出现.

  1. 您的互联网防火墙阻止了与google的连接:请尝试 在您的laravel主机中ping android.googleapis.com.或curl -v gcm-http.googleapis.com如果没有响应,则被阻止.

  1. Your internet firewall block the connection to the google : pls try ping android.googleapis.com in your laravel host. or curl -v gcm-http.googleapis.com if doesn't response then it is blocked.

打开您的端口以供Google api使用,我通常打开4435528-2230的端口.您可以在防火墙中配置

Open your the port for google api to work, I open the port usually 443 , 5528-2230. you might configure in your firewall

gcm-http.googleapis.com具有很多IP地址,因此您需要允许来自这些IP地址的连接,这是其IP地址之一:172.217.3.170. 通过允许其IP地址范围之间的连接来解决问题.您可以在防火墙软件中监视IP地址.

the gcm-http.googleapis.com has a lot of ip addresses, so you need to allow connection from these ip addresses this is one of their ip address : 172.217.3.170. mine solve the problem by allowing the connection between the range of their ip addresses. you can monitor the ip address in your firewall software.

您可以在此处此处

这取决于您的防火墙配置,您需要与配置防火墙的人员一起设置它们,因为我假设您在安全的网络环境中工作.

it depends on your firewall configuration you need to setup those with the guy who configure the firewall since I assume you work in the secure network environment.

这篇关于无法连接到www.googleapis.com端口443:网络无法访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆