gpt4 book ai didi

Python 请求和 OpenSSL - 超过 HTTPSConnectionPool 最大重试次数

转载 作者:行者123 更新时间:2023-11-28 19:29:33 28 4
gpt4 key购买 nike

执行以下脚本时,我在 Ubuntu 14.04 中使用 python 请求库时遇到问题:

import requests
import json

payload = {'code':'TG-000000000000000000000000', 'client_secret':'X0000000000000000000000000000000', 'grant_type':'authorization_code', 'client_id':'1111111111111111', 'redirect_uri':'http://127.0.0.1:8000/mercadolibre/process_ml_response/'}
headers = {'content-type': 'application/x-www-form-urlencoded'}
requests.post("https://api.mercadolibre.com:443/oauth/token", data=payload, headers=headers)

我得到以下回溯

  File "<stdin>", line 1, in <module>
File "/home/theuser/.virtualenvs/tumoto/local/lib/python2.7/site-packages/requests/api.py", line 88, in post
return request('post', url, data=data, **kwargs)
File "/home/theuser/.virtualenvs/tumoto/local/lib/python2.7/site-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/home/theuser/.virtualenvs/tumoto/local/lib/python2.7/site-packages/requests/sessions.py", line 456, in request
resp = self.send(prep, **send_kwargs)
File "/home/theuser/.virtualenvs/tumoto/local/lib/python2.7/site-packages/requests/sessions.py", line 559, in send
r = adapter.send(request, **kwargs)
File "/home/theuser/.virtualenvs/tumoto/local/lib/python2.7/site-packages/requests/adapters.py", line 375, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.mercadolibre.com', port=443): Max retries exceeded with url: /oauth/token (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)

如果我在 Ubuntu 13.10 中尝试相同的代码工作正常

我猜这个错误与 openssl (1.0.1f) 的版本有关,并请求 python 库

我尝试按照 using requests with TLS doesn't give SNI support 中的建议安装 pyOpenSSL、ndg-httpsclient 和 pyasn1,但没有用,在运行脚本之前也应用了 monkey 补丁,但也失败了

注意:当我使用 pyOpenSSL 时,我得到的新错误是:

request.exceptions.SSLError: [Errno bad handshake](104, 'ECONNRESET') 

谢谢你的建议

最佳答案

我发现了一个请求的分支,它可以很好地与 Ubuntu 14.04 的 OpenSSL 版本一起工作,https://github.com/joequery/requests-sslv3仅通过 pip 安装此 fork 并且 requests 再次运行良好

关于Python 请求和 OpenSSL - 超过 HTTPSConnectionPool 最大重试次数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24422096/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com