我在Cygwin中运行Python程序以连接到AWS,但由于超时而一直失败。但是我在Cygwin中使用aws cli与AWS的连接始终有效。此外,如果我在Windows中运行相同的python代码,它也可以工作。我已经检查了所有连接凭据,这些凭据对所有人都是一样的。
这是错误消息:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/boto-2.38.0-py2.7.egg/boto/ec2/connection.py", line 585, in get_all_instances
max_results=max_results)
File "/usr/lib/python2.7/site-packages/boto-2.38.0-py2.7.egg/boto/ec2/connection.py", line 681, in get_all_reservations
[('item', Reservation)], verb='POST')
File "/usr/lib/python2.7/site-packages/boto-2.38.0-py2.7.egg/boto/connection.py", line 1170, in get_list
response = self.make_request(action, params, path, verb)
File "/usr/lib/python2.7/site-packages/boto-2.38.0-py2.7.egg/boto/connection.py", line 1116, in make_request
return self._mexe(http_request)
File "/usr/lib/python2.7/site-packages/boto-2.38.0-py2.7.egg/boto/connection.py", line 1030, in _mexe
raise ex
socket.error: [Errno 116] Connection timed out
答案 0 :(得分:2)
我发现罪魁祸首在于代理凭据。
我将HTTP_PROXY
和HTTPS_PROXY
作为Windows环境变量。但是,当在Cygwin中运行时,boto使用'http_proxy'进行匹配而不考虑单词的情况
(see /boto/connection.py(669)handle_proxy()
line 669: if 'http_proxy' in os.environ and not self.proxy:).
当我将大写字母HTTP_PROXY
更改为小写http_proxy
时,它就有效了。如果我在Windows中使用Python运行,不确定为什么它不是问题。