gcloud与服务器的连接超时

时间:2017-02-16 21:39:09

标签: google-bigquery gcloud google-api-python-client

我在尝试使用gcloud时遇到了麻烦。尝试从BigQuery加载数据时,我在python客户端上获得超时。我也无法连接到bq shell。当我尝试运行gcloud init时,我无法通过网络诊断程序。我该如何解决这个问题?

发出运行命令[gcloud init]。

<ipython-input-1-b62ec78494d7> in get_bigquery_connection()
     23 def get_bigquery_connection():
     24     credentials = GoogleCredentials.get_application_default()
---> 25     bigquery = discovery.build('bigquery', 'v2', credentials=credentials)
     26 
     27     return bigquery

/home/ricardo/worspace/news_crawler/venv/lib/python2.7/site-packages/oauth2client/_helpers.pyc in positional_wrapper(*args, **kwargs)
    131                 elif positional_parameters_enforcement == POSITIONAL_WARNING:
    132                     logger.warning(message)
--> 133             return wrapped(*args, **kwargs)
    134         return positional_wrapper
    135 

/home/ricardo/worspace/news_crawler/venv/lib/python2.7/site-packages/googleapiclient/discovery.pyc in build(serviceName, version, http, discoveryServiceUrl, developerKey, model, requestBuilder, credentials, cache_discovery, cache)
    226     try:
    227       content = _retrieve_discovery_doc(
--> 228         requested_url, discovery_http, cache_discovery, cache)
    229       return build_from_document(content, base=discovery_url, http=http,
    230           developerKey=developerKey, model=model, requestBuilder=requestBuilder,

/home/ricardo/worspace/news_crawler/venv/lib/python2.7/site-packages/googleapiclient/discovery.pyc in _retrieve_discovery_doc(url, http, cache_discovery, cache)
    273   logger.info('URL being requested: GET %s', actual_url)
    274 
--> 275   resp, content = http.request(actual_url)
    276 
    277   if resp.status >= 400:

/home/ricardo/worspace/news_crawler/venv/lib/python2.7/site-packages/httplib2/__init__.pyc in request(self, uri, method, body, headers, redirections, connection_type)
   1657                     content = ""
   1658                 else:
-> 1659                     (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
   1660         except Exception, e:
   1661             if self.force_exception_to_status_code:

/home/ricardo/worspace/news_crawler/venv/lib/python2.7/site-packages/httplib2/__init__.pyc in _request(self, conn, host, absolute_uri, request_uri, method, body, headers, redirections, cachekey)
   1397             auth.request(method, request_uri, headers, body)
   1398 
-> 1399         (response, content) = self._conn_request(conn, request_uri, method, body, headers)
   1400 
   1401         if auth:

/home/ricardo/worspace/news_crawler/venv/lib/python2.7/site-packages/httplib2/__init__.pyc in _conn_request(self, conn, request_uri, method, body, headers)
   1317             try:
   1318                 if hasattr(conn, 'sock') and conn.sock is None:
-> 1319                     conn.connect()
   1320                 conn.request(method, request_uri, body, headers)
   1321             except socket.timeout:

/home/ricardo/worspace/news_crawler/venv/lib/python2.7/site-packages/httplib2/__init__.pyc in connect(self)
   1063                 if has_timeout(self.timeout):
   1064                     sock.settimeout(self.timeout)
-> 1065                 sock.connect((self.host, self.port))
   1066                 self.sock =_ssl_wrap_socket(
   1067                     sock, self.key_file, self.cert_file,

/usr/lib/python2.7/socket.pyc in meth(name, self, *args)
    226 
    227 def meth(name,self,*args):
--> 228     return getattr(self._sock,name)(*args)
    229 
    230 for _m in _socketmethods:

timeout: timed out

安装信息:

Google Cloud SDK [135.0.0]

Platform: [Linux, x86_64]
Python Version: [2.7.9 (default, Apr  2 2015, 15:33:21)  [GCC 4.9.2]]
Python Location: [/usr/bin/python2]
Site Packages: [Disabled]

Installation Root: [/home/ricardo/google-cloud-sdk]
Installed Components:
  core: [2016.11.11]
  core-nix: [2016.11.07]
  kubectl: []
  gcloud: []
  gsutil-nix: [4.18]
  gsutil: [4.22]
  bq: [2.0.24]
  kubectl-linux-x86_64: [1.4.4]
  bq-nix: [2.0.24]
System PATH: [/home/ricardo/google-cloud-sdk/bin:/home/ricardo/.local/share/umake/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games]
Cloud SDK on PATH: [True]
Kubectl on PATH: [/home/ricardo/google-cloud-sdk/bin/kubectl]

WARNING: There are old versions of the Google Cloud Platform tools on your system PATH.
  /usr/lib/google-cloud-sdk/bin/git-credential-gcloud.sh
  /usr/lib/google-cloud-sdk/bin/gsutil
  /usr/lib/google-cloud-sdk/bin/bq
  /usr/lib/google-cloud-sdk/bin/gcloud

Installation Properties: [/home/ricardo/google-cloud-sdk/properties]
User Config Directory: [/home/ricardo/.config/gcloud]
Active Configuration Name: [default]
Active Configuration Path: [/home/ricardo/.config/gcloud/configurations/config_default]

Account: [None]
Project: [None]

Current Properties:
  [core]
[output truncated]

编辑:

重要的是要说每当我运行gcloud auth login浏览器弹出时,我登录然后重定向到成功页面但终端期待某些东西......我相信问题就在这里

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题。我的解决方法是直接从 cli 强制登录:gcloud

<块引用>

授权登录 --no-launch-browser

您将获得一个链接以手动通过浏览器进行身份验证。在您进行身份验证并允许访问后,您可以将确认代码复制回您的云 SDK 外壳。

相关问题