python - 将 GCP 服务与 python 和代理一起使用
问题描述
在工作中,我们有一个代理,经典设置。
我尝试使用我的 python 脚本访问 GCS 存储桶中的文件或在 BigQuery 表上读/写。在另一个网络上一切正常。
我已经在 Ubuntu 上HTTP_PROXY
使用代理的 URL 设置了我的环境。HTTPS_PROXY
我还apt
为浏览器设置了值。我可以apt update
,git clone
...但是一些简单的事情是df = pd.read_csv("gs://.......")
行不通的。
我什至配置gcloud
为设置代理的值。
$ gcloud config list
[compute]
region = europe-west1
zone = europe-west1-c
[core]
account = me@myself.org
disable_usage_reporting = True
project = world-anhilation-666
[proxy]
address = proxy.net
port = 8080
type = http
Your active configuration is: [default]
该脚本运行超过 10 分钟并给了我错误:
Cannot connect to host www.googleapis.com:443 ssl:default [Network is unreachable]
解决方案
你可以尝试几个选项来解决这个问题
您的 Internet 防火墙阻止了与 google api 的连接:尝试在您的 laravel 主机中 ping android.googleapis.com。或 curl -v gcm-http.googleapis.com 如果它没有响应,很可能它被阻止了。
打开你的端口让google api工作,确保443是开放的,5528-2230。它可能需要在您的防火墙中进行配置
gcm-http.googleapis.com 有很多 ip 地址,所以你需要允许来自这些 ip 地址的连接。这是他们的 IP 地址之一:172.217.24.234 。您可以监控防火墙中的 IP 地址。
您可以在此链接 [1] 和 [2] 上找到 google api IP 地址的范围
[1] https://whois.domaintools.com/172.217.24.234 [2] http://whois.domaintools.com/216.58.196.202
推荐阅读
- axapta - 请求“InteropPermission”类型的权限失败。”。无法创建对象
- java - Java,哈希图,无法打印值(对象)
- r - 创建两个指标(虚拟)变量
- mysql - 无法更新存储触发器中的表,因为它已被调用此存储触发器的语句使用
- javascript - 如何使用 javascript/jquery 更改 flexbox 元素的宽度
- maven - 如何将部署配置保留在已部署的 pom.xml 之外?
- c# - 如何自动更新对象引用
- javascript - 如何将活动类添加到 onclick 元素?
- javascript - 如何将自定义 js 添加到 HTML
- laravel - Laravel 表单使用不正确的记录 ID 进行删除