【发布时间】:2019-01-18 01:11:56
【问题描述】:
当 Google Compute Engine 实例(使用 Container-Optimized OS 映像)启动并且 dockerized 应用程序工作时,下面的脚本应该将数据发送到 url。 不幸的是,即使它无法发布数据,应用程序运行时也会收到数据。
输出是:
('错误', ConnectionError(MaxRetryError("HTTPConnectionPool(host='34.7.8.8', port=12345): url: /didi.json 超出了最大重试次数(由 NewConnectionError(': 建立新连接失败: [Errno 111] 连接被拒绝',))",),))
它来自 GCE 吗?
这里是python代码:
for i in range(0,100):
while True:
try:
response = requests.post('http://%s:12345/didi.json' % ip_of_instance, data=data)
except requests.exceptions.RequestException as err:
print ("Error",err)
time.sleep(2)
continue
break
编辑 - 这里是发布请求的参数:
data = {
'url': 'www.website.com',
'project': 'webCrawl',
'spider': 'indexer',
'setting': 'ELASTICSEARCH_SERVERS=92.xx.xx.xx',
'protocol': 'https',
'scraper': 'light'
}
【问题讨论】:
-
您能否在发布请求中提供更多详细信息,例如您要执行的操作?
-
是的,我刚刚做到了:)
标签: python google-compute-engine google-container-os