连接使用Heroku上的Python-Requests重置连接

时间:2014-12-11 00:09:39

标签: python heroku python-requests

我想知道我是否可以帮助解决我遇到的问题。

我正在使用请求从api中提取一些数据,用于我正在Heroku上部署的Web应用程序。在我的本地计算机上,我没有问题连接到API并提取数据,但是当我部署到Heroku时,它将无法工作。 (当我尝试在Cloud 9 IDE上进行测试时,会发生同样的事情)

以下示例代码:

email = 'example@example.com'
url = 'https://api.example.com/'
auth = ('example', 'example')
headers = {'Accept': 'application/json', 'content-type': 'application/json'}
params = {'emailaddress': email}

r = requests.get(url+'customer.svc/search', params=params, auth=auth, headers=headers)

这是非常基本的,但我无法让它发挥作用。

每次我尝试连接时都会收到错误:

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.example.com', port=443): Max retries exceeded with url: /customer.svc/search?emailaddress=example%40example.com (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)

我是Heroku的新手,所以这可能是基本的。我错过了什么?

编辑:

似乎错误只发生在我部署代码时。我已经尝试了几台机器上的代码,我对请求没有任何问题。我想知道它是否与回到我的Heroku应用程序的连接有关?

0 个答案:

没有答案
相关问题