【发布时间】:2016-01-28 20:58:24
【问题描述】:
我已经看到很多关于“对等连接重置”和 Python 的不同问题,但是,我认为这个问题是不同的。
问题是:我正在尝试通过 https 访问与我在同一网络中的 Web 服务。我通过 Python 执行调用的每一次尝试都返回了“对等方重置连接”。我在 Linux 上运行它。
但是,我可以通过浏览器进行 Curl 和访问 Web 服务,没有任何麻烦。此外,同样的脚本也适用于 Windows 和其他 Linux 环境(尽管它们运行的是 Python 2.7)。
我已经尝试了这两个请求并使用了 base urllib.request。
# I specify blank proxy since I have CNTLM setup for outbound.
requests.get(url, proxies={'https': ''}, auth=(user, pass), verify=False)
我也试过了:
session = requests.Session()
session.trust_env=False
# This still brings up 'Connection reset by peer' with/without http auth
response = session.get(url)
我已经尝试了很长的路......
import urrlib
proxy_handler = urllib.request.ProxyHandler({})
proxy_opener = urllib.request.build_opener(proxy_handler)
urllib.request.install_opener(proxy_opener)
# do the same for basic auth....
resp = urllib.request.urlopen(url)
有什么想法吗?
【问题讨论】:
标签: python-3.x python-requests urllib