简体   繁体   English

Python - 第一次请求时如何获得 SSL 错误(url 超出最大重试次数)?

[英]Python - How is it possible to get SSL Error (Max retries exceeded with url) at first request?

Here's my code:这是我的代码:

import requests

url = "https://api.vidal.fr/rest/api/products?app_id=MY_ID&app_key=MY_KEY&q=doliprane"

response = requests.get(url, verify=False)

print(response.text.encode('utf8'))

And this is the error I get:这是我得到的错误:

Traceback (most recent call last):
  File "get_classes.py", line 6, in <module>
    response = requests.get(url, verify=False)
  File "/Users/christou/Library/Python/2.7/lib/python/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/Users/christou/Library/Python/2.7/lib/python/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/christou/Library/Python/2.7/lib/python/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/christou/Library/Python/2.7/lib/python/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/Users/christou/Library/Python/2.7/lib/python/site-packages/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.vidal.fr', port=443): Max retries exceeded with url: /rest/api/products?app_id=MY_ID&app_key=MY_KEY&q=doliprane (Caused by SSLError(SSLEOFError(8, u'EOF occurred in violation of protocol (_ssl.c:590)'),))

My code is pretty simple, and after some research I understand the problem is probably coming from an wrong certificate (although the 'verify=False' doesn't help) or maybe old versions (Python or SSL)...我的代码非常简单,经过一些研究,我了解到问题可能来自错误的证书(尽管 'verify=False' 没有帮助)或者可能是旧版本(Python 或 SSL)......

Don't let the error message mislead you, this is the very first request I made to this API.不要让错误信息误导你,这是我对这个 API 提出的第一个请求。 At this point can't exceed any maximum number of requests.此时不能超过任何最大请求数。 When I copy/paste the URL in my browser it works perfectly.当我在浏览器中复制/粘贴 URL 时,它可以正常工作。

What should I do?我应该怎么办?

I understand the problem is probably coming from an wrong certificate...我知道问题可能来自错误的证书......

No. Server certificate validation is done locally and does not result in the shown error.不会。服务器证书验证在本地完成,不会导致显示的错误。

... or maybe old versions (Python or SSL) ...或者可能是旧版本(Python 或 SSL)

More likely.更倾向于。 Nothing is known about your versions of Python (except that it is 2.7.whatever) and openssl, but this error for example happens if your openssl does not support TLS 1.1 or TLS 1.2 since TLS 1.0 is disabled on the server. Nothing is known about your versions of Python (except that it is 2.7.whatever) and openssl, but this error for example happens if your openssl does not support TLS 1.1 or TLS 1.2 since TLS 1.0 is disabled on the server. For example MacOS came for years with a very old version of openssl which caused such errors.例如,MacOS 多年来一直使用非常旧的 openssl 版本,这会导致此类错误。

It might also a problem with some firewall blocking the connections during the TLS handshake.某些防火墙在 TLS 握手期间阻止连接也可能存在问题。 Hard to tell.很难说。 But you might try to access the site from the same machine with a different client to narrow down the problem.但是您可能会尝试从具有不同客户端的同一台计算机访问该站点以缩小问题范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python请求“ URL超过最大重试次数”错误 - Python requests “Max retries exceeded with url” error 错误:Python 中的 url 超出了最大重试次数 - Error: Max retries exceeded with url in Python 如何解决python请求错误:“Max retries exceeded with url” - How solve python requests error: “Max retries exceeded with url” 超过 url 的 Python Max 重试次数 - Python Max retries exceeded with url url Tensorflow Serving Python Request 超过了最大重试次数 - Max retries exceeded with url Tensorflow Serving Python Request Snowflake AWS Privatelink - Python 连接器错误最大重试次数超过 url:/session/v1/login-request? - Snowflake AWS Privatelink - Python Connector Error Max retries exceeded with url: /session/v1/login-request? Python 模块 googletrans 抛出“超过 url:/ 的最大重试次数”错误 - Python module googletrans throwing "Max retries exceeded with url: /" error 处理 Python 中的 Firebase 'Max retries exceeded with url' 错误 - Handling Firebase 'Max retries exceeded with url' error in Python 使用 requests.get() 时 URL 错误超出最大重试次数 - Max retries exceeded with URL Error on using requests.get() SSLError:最大重试次数超出了 url 错误? 如何解决这个问题? - SSLError: max retries exceeded with url error? How to fix this?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM