Python3 + vagrant ubuntu 16.04 + ssl request = [Errno 104] 连接被对等重置

Python3 + vagrant ubuntu 16.04 + ssl request = [Errno 104] Connection reset by peer

我正在 Mac Vagrant 上使用 "bento/ubuntu-16.04" 盒子。我正在尝试通过 python 库使用 Google Adwords Api 但出现错误 [Errno 104] Connection reset by peer

我制作示例脚本来检查发送请求的可能性:

import urllib.request

url ="https://adwords.google.com/api/adwords/mcm/v201609/ManagedCustomerService?wsdl"
f = urllib.request.urlopen(url)
print(f.read())

如果我通过 python3 尝试此请求 - 我有 [Errno 104] Connection reset by peer。 但是,如果我通过 curl curl https://adwords.google.com/api/adwords/mcm/v201609/ManagedCustomerService?wsdl 发送请求 - 我会收到一些带有正文的响应(即使它是 500 代码)。

如果我从主机 Mac 机器上尝试此示例 python 脚本 - 我还会收到一些文本响应。 我使用 ubuntu 16.04 从 VDS 服务器尝试了这个脚本 - 也有效。

所以我假设 Vagrant/Mac.

之间可能存在问题

也许你能帮帮我?

谢谢。

我找到了解决方案。它看起来像 Virtualbox 5.1.8 版本中的错误。你可以阅读它 here

因此,您可以通过将 Virtualbox 降级到 < 5.1.6 来修复它