Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1108 #2746

Open
lmx760581375 opened this issue Jan 13, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@lmx760581375
Copy link

Describe the bug

when i want to download some dataset through my access token, it happen:

(test) [root@VM-143-158-tencentos utils]# python3 hub_download.py
Downloading repo: lmms-lab/OK-VQA
Traceback (most recent call last):
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/connectionpool.py", line 466, in _make_request
self._validate_conn(conn)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1095, in _validate_conn
conn.connect()
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/connection.py", line 730, in connect
sock_and_verified = _ssl_wrap_socket_and_match_hostname(
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/connection.py", line 909, in ssl_wrap_socket_and_match_hostname
ssl_sock = ssl_wrap_socket(
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/util/ssl
.py", line 469, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/util/ssl
.py", line 513, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "/root/anaconda3/envs/test/lib/python3.8/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/root/anaconda3/envs/test/lib/python3.8/ssl.py", line 1040, in _create
self.do_handshake()
File "/root/anaconda3/envs/test/lib/python3.8/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1108)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/connectionpool.py", line 789, in urlopen
response = self._make_request(
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/connectionpool.py", line 490, in _make_request
raise new_e
urllib3.exceptions.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1108)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/requests/adapters.py", line 667, in send
resp = conn.urlopen(
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/connectionpool.py", line 843, in urlopen
retries = retries.increment(
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/util/retry.py", line 519, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/datasets/lmms-lab/OK-VQA/tree/main?recursive=True&expand=False (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1108)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "hub_download.py", line 81, in
get_huggingface(args.repo_id, args.repo_type, args.cachedir, args.custom_path, num_threads=args.num_threads, revision=args.revision)
File "hub_download.py", line 46, in get_huggingface
files = api.list_repo_files(repo_id=repo_id, repo_type=repo_type, token=token_id, revision=revision)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 2935, in list_repo_files
return [
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 2935, in
return [
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 3072, in list_repo_tree
for path_info in paginate(path=tree_url, headers=headers, params={"recursive": recursive, "expand": expand}):
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/huggingface_hub/utils/_pagination.py", line 36, in paginate
r = session.get(path, params=params, headers=headers)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/requests/sessions.py", line 602, in get
return self.request("GET", url, **kwargs)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/huggingface_hub/utils/_http.py", line 93, in send
return super().send(request, *args, **kwargs)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/requests/adapters.py", line 698, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/datasets/lmms-lab/OK-VQA/tree/main?recursive=True&expand=False (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1108)')))"), '(Request ID: 3168ac25-e3e5-4660-b340-53eec9f4aaba)')

Reproduction

No response

Logs

System info

(test) [root@VM-143-158-tencentos utils]# huggingface-cli env

Copy-and-paste the text below in your GitHub issue.

- huggingface_hub version: 0.27.1
- Platform: Linux-5.4.32-1-tlinux4-0001-x86_64-with-glibc2.10
- Python version: 3.8.0
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Running in Google Colab Enterprise ?: No
- Token path ?: /root/.cache/huggingface/token
- Has saved token ?: False
- Configured git credential helpers: 
- FastAI: N/A
- Tensorflow: 2.10.1
- Torch: 2.1.2+cu118
- Jinja2: 3.1.2
- Graphviz: N/A
- keras: 2.10.0
- Pydot: N/A
- Pillow: 10.1.0
- hf_transfer: N/A
- gradio: 4.29.0
- tensorboard: N/A
- numpy: 1.24.4
- pydantic: 2.7.4
- aiohttp: 3.8.5
- ENDPOINT: https://huggingface.co
- HF_HUB_CACHE: /root/.cache/huggingface/hub
- HF_ASSETS_CACHE: /root/.cache/huggingface/assets
- HF_TOKEN_PATH: /root/.cache/huggingface/token
- HF_STORED_TOKENS_PATH: /root/.cache/huggingface/stored_tokens
- HF_HUB_OFFLINE: False
- HF_HUB_DISABLE_TELEMETRY: False
- HF_HUB_DISABLE_PROGRESS_BARS: None
- HF_HUB_DISABLE_SYMLINKS_WARNING: False
- HF_HUB_DISABLE_EXPERIMENTAL_WARNING: False
- HF_HUB_DISABLE_IMPLICIT_TOKEN: False
- HF_HUB_ENABLE_HF_TRANSFER: False
- HF_HUB_ETAG_TIMEOUT: 10
- HF_HUB_DOWNLOAD_TIMEOUT: 10

(test) [root@VM-143-158-tencentos utils]#
@lmx760581375 lmx760581375 added the bug Something isn't working label Jan 13, 2025
@Wauplin
Copy link
Contributor

Wauplin commented Jan 13, 2025

Hi @lmx760581375, sorry for your issue. This is very likely not due to huggingface_hub library but to either a corrupted environment or a invalid proxy/firewall setup. What I advice you to do:

  1. upgrade packages:
pip install --upgrade requests urllib3 huggingface_hub
  1. test on a single HTTP call:
import requests
response = requests.get("https://huggingface.co")
print(response.status_code)

if the problem persists, check with your internet provider or network admin how this could be fixed.

@lmx760581375
Copy link
Author

Thank you for your response, i have try this code, the results:

(test) [root@VM-143-158-tencentos ~]# python3
Python 3.8.0 (default, Nov 6 2019, 21:49:08)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.

import requests
response = requests.get("https://huggingface.co")
Traceback (most recent call last):
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/connectionpool.py", line 466, in _make_request
self._validate_conn(conn)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1095, in _validate_conn
conn.connect()
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/connection.py", line 730, in connect
sock_and_verified = _ssl_wrap_socket_and_match_hostname(
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/connection.py", line 909, in ssl_wrap_socket_and_match_hostname
ssl_sock = ssl_wrap_socket(
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/util/ssl
.py", line 469, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/util/ssl
.py", line 513, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "/root/anaconda3/envs/test/lib/python3.8/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/root/anaconda3/envs/test/lib/python3.8/ssl.py", line 1040, in _create
self.do_handshake()
File "/root/anaconda3/envs/test/lib/python3.8/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1108)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/connectionpool.py", line 789, in urlopen
response = self._make_request(
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/connectionpool.py", line 490, in _make_request
raise new_e
urllib3.exceptions.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1108)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/requests/adapters.py", line 667, in send
resp = conn.urlopen(
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/connectionpool.py", line 843, in urlopen
retries = retries.increment(
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/urllib3/util/retry.py", line 519, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1108)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/requests/api.py", line 73, in get
return request("get", url, params=params, **kwargs)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/requests/adapters.py", line 698, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1108)')))

@lmx760581375
Copy link
Author

import requests
response = requests.get("http://huggingface.co")
print(response.status_code)
502
response
<Response [502]>
response.json
<bound method Response.json of <Response [502]>>
response.json()
Traceback (most recent call last):
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/requests/models.py", line 974, in json
return complexjson.loads(self.text, **kwargs)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/simplejson/init.py", line 514, in loads
return _default_decoder.decode(s)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/simplejson/decoder.py", line 386, in decode
obj, end = self.raw_decode(s)
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/simplejson/decoder.py", line 416, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/root/anaconda3/envs/test/lib/python3.8/site-packages/requests/models.py", line 978, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

print(response)
<Response [502]>
print(response.content)
b''
print(response.text)

@Wauplin
Copy link
Contributor

Wauplin commented Jan 13, 2025

As mentioned in my comment above, I'd recommend checking your SSL installation + contact your network admin. This issue has nothing to do with huggingface_hub since even a simple requests.get("https://huggingface.co") is failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants