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 error #240

Closed
amelksibi2019 opened this issue Nov 11, 2019 · 12 comments
Closed

SSL error #240

amelksibi2019 opened this issue Nov 11, 2019 · 12 comments

Comments

@amelksibi2019
Copy link

when I tried this statement,

twitterscraper "Trump OR Clinton" --limit 100 --output=tweets.json
I obtained the following error:

INFO: {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201'}
Traceback (most recent call last):
File "c:\users\amel\anaconda3\lib\site-packages\urllib3\contrib\pyopenssl.py", line 453, in wrap_socket
cnx.do_handshake()
File "c:\users\amel\anaconda3\lib\site-packages\OpenSSL\SSL.py", line 1915, in do_handshake
self._raise_ssl_error(self._ssl, result)
File "c:\users\amel\anaconda3\lib\site-packages\OpenSSL\SSL.py", line 1639, in _raise_ssl_error
raise SysCallError(errno, errorcode.get(errno))
OpenSSL.SSL.SysCallError: (10054, 'WSAECONNRESET')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\amel\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "c:\users\amel\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "c:\users\amel\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 839, in validate_conn
conn.connect()
File "c:\users\amel\anaconda3\lib\site-packages\urllib3\connection.py", line 344, in connect
ssl_context=context)
File "c:\users\amel\anaconda3\lib\site-packages\urllib3\util\ssl
.py", line 344, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "c:\users\amel\anaconda3\lib\site-packages\urllib3\contrib\pyopenssl.py", line 459, in wrap_socket
raise ssl.SSLError('bad handshake: %r' % e)
ssl.SSLError: ("bad handshake: SysCallError(10054, 'WSAECONNRESET')",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\amel\anaconda3\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "c:\users\amel\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "c:\users\amel\anaconda3\lib\site-packages\urllib3\util\retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='free-proxy-list.net', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError("bad handshake: SysCallError(10054, 'WSAECONNRESET')")))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\amel\anaconda3\lib\runpy.py", line 193, in run_module_as_main
"main", mod_spec)
File "c:\users\amel\anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\Amel\Anaconda3\Scripts\twitterscraper.exe_main
.py", line 5, in
File "c:\users\amel\anaconda3\lib\site-packages\twitterscraper_init
.py", line 13, in
from twitterscraper.query import query_tweets
File "c:\users\amel\anaconda3\lib\site-packages\twitterscraper\query.py", line 73, in
proxies = get_proxies()
File "c:\users\amel\anaconda3\lib\site-packages\twitterscraper\query.py", line 43, in get_proxies
response = requests.get(PROXY_URL)
File "c:\users\amel\anaconda3\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "c:\users\amel\anaconda3\lib\site-packages\requests\api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "c:\users\amel\anaconda3\lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "c:\users\amel\anaconda3\lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "c:\users\amel\anaconda3\lib\site-packages\requests\adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='free-proxy-list.net', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError("bad handshake: SysCallError(10054, 'WSAECONNRESET')")))

C:>

@avanibhatnagar
Copy link

@amelksibi2019 Hey were you able to get past this error?

@shradha-khapra
Copy link

@amelksibi2019 Hey, I am getting a similar error after running : twitterscraper Trump --limit 100 --output=tweets.json
Could you please help me get past it?
error:
INFO: {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; x64; fr; rv:1.9.2.13) Gecko/20101203 Firebird/3.6.13'}
Traceback (most recent call last):
File "/home/shradha/anaconda3/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 441, in wrap_socket
cnx.do_handshake()
File "/home/shradha/anaconda3/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1716, in do_handshake
self._raise_ssl_error(self._ssl, result)
File "/home/shradha/anaconda3/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1448, in _raise_ssl_error
raise SysCallError(errno, errorcode.get(errno))
OpenSSL.SSL.SysCallError: (104, 'ECONNRESET')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/shradha/anaconda3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/home/shradha/anaconda3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "/home/shradha/anaconda3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 850, in validate_conn
conn.connect()
File "/home/shradha/anaconda3/lib/python3.6/site-packages/urllib3/connection.py", line 326, in connect
ssl_context=context)
File "/home/shradha/anaconda3/lib/python3.6/site-packages/urllib3/util/ssl
.py", line 329, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/home/shradha/anaconda3/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 448, in wrap_socket
raise ssl.SSLError('bad handshake: %r' % e)
ssl.SSLError: ("bad handshake: SysCallError(104, 'ECONNRESET')",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/shradha/anaconda3/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/home/shradha/anaconda3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/shradha/anaconda3/lib/python3.6/site-packages/urllib3/util/retry.py", line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='free-proxy-list.net', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError("bad handshake: SysCallError(104, 'ECONNRESET')",),))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/shradha/anaconda3/bin/twitterscraper", line 11, in
load_entry_point('twitterscraper==1.4.0', 'console_scripts', 'twitterscraper')()
File "/home/shradha/anaconda3/lib/python3.6/site-packages/pkg_resources/init.py", line 570, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/home/shradha/anaconda3/lib/python3.6/site-packages/pkg_resources/init.py", line 2751, in load_entry_point
return ep.load()
File "/home/shradha/anaconda3/lib/python3.6/site-packages/pkg_resources/init.py", line 2405, in load
return self.resolve()
File "/home/shradha/anaconda3/lib/python3.6/site-packages/pkg_resources/init.py", line 2411, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/home/shradha/anaconda3/lib/python3.6/site-packages/twitterscraper/init.py", line 13, in
from twitterscraper.query import query_tweets
File "/home/shradha/anaconda3/lib/python3.6/site-packages/twitterscraper/query.py", line 73, in
proxies = get_proxies()
File "/home/shradha/anaconda3/lib/python3.6/site-packages/twitterscraper/query.py", line 43, in get_proxies
response = requests.get(PROXY_URL)
File "/home/shradha/anaconda3/lib/python3.6/site-packages/requests/api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "/home/shradha/anaconda3/lib/python3.6/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/home/shradha/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/home/shradha/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/home/shradha/anaconda3/lib/python3.6/site-packages/requests/adapters.py", line 506, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='free-proxy-list.net', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError("bad handshake: SysCallError(104, 'ECONNRESET')",),))

@Blackbird002
Copy link

What OS are you running it on? We're experiencing similar issues on macOS.

@mysterefrank
Copy link

Got the same error on OSX

@Blackbird002
Copy link

Interesting... My team ran twitterscraper just fine on Windows 10 and Ubuntu 18.04 LTS. Looks like this issue is exclusive to macOS?

@youssefsaqr
Copy link

no it is not exclusive to macOS, I'm running on windows 10 and it is giving me the same error. and this happens only for this statement

from twitterscraper.query import query_user_info

@mysterefrank
Copy link

I just gave up

@lapp0
Copy link
Collaborator

lapp0 commented Jun 7, 2020

@youssefsaqr @mysterefrank @amelksibi2019 are you still experiencing this issue?

I cannot reproduce you try this solution? psf/requests#4246 (comment)

Please ping me or start a new issue if you have further questions

@lapp0 lapp0 closed this as completed Jun 7, 2020
@glen-cote
Copy link

I think this is related - I can't get from twitterscraper import query_tweets to work. I get this error message and it has something to do with a bad handshake with SSL. I've tried updating the python version and reinstalling twitterscraper but it doesn't work. I'm on macOS Catalina Version 10.15.5

INFO: {'User-Agent': 'Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'}
Traceback (most recent call last):
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 976, in _validate_conn
    conn.connect()
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/site-packages/urllib3/connection.py", line 361, in connect
    self.sock = ssl_wrap_socket(
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 377, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/Users/glencote/.pyenv/versions/3.8.3/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 "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 724, in urlopen
    retries = retries.increment(
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/site-packages/urllib3/util/retry.py", line 439, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='free-proxy-list.net', 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 "please_work.py", line 1, in <module>
    from twitterscraper import query_tweets
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/site-packages/twitterscraper/__init__.py", line 13, in <module>
    from twitterscraper.query import query_tweets
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/site-packages/twitterscraper/query.py", line 73, in <module>
    proxies = get_proxies()
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/site-packages/twitterscraper/query.py", line 43, in get_proxies
    response = requests.get(PROXY_URL)
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/Users/glencote/.pyenv/versions/3.8.3/lib/python3.8/site-packages/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='free-proxy-list.net', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1108)')))

@maldil
Copy link

maldil commented Sep 19, 2020

Even though this issue is closed, I just witnessed this error. I am using MacOS.

@CoastalBoltman
Copy link

Just experienced the error using Ubuntu 20.04 by simply doing
import twitterscraper

---------------------------------------------------------------------------
SSLError                                  Traceback (most recent call last)
/usr/lib/python3/dist-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    664             # Make the request on the httplib connection object.
--> 665             httplib_response = self._make_request(
    666                 conn,

/usr/lib/python3/dist-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    375         try:
--> 376             self._validate_conn(conn)
    377         except (SocketTimeout, BaseSSLError) as e:

/usr/lib/python3/dist-packages/urllib3/connectionpool.py in _validate_conn(self, conn)
    995         if not getattr(conn, "sock", None):  # AppEngine might not have  `.sock`
--> 996             conn.connect()
    997 

/usr/lib/python3/dist-packages/urllib3/connection.py in connect(self)
    351 
--> 352         self.sock = ssl_wrap_socket(
    353             sock=conn,

/usr/lib/python3/dist-packages/urllib3/util/ssl_.py in ssl_wrap_socket(sock, keyfile, certfile, cert_reqs, ca_certs, server_hostname, ssl_version, ciphers, ssl_context, ca_cert_dir, key_password)
    369         if HAS_SNI and server_hostname is not None:
--> 370             return context.wrap_socket(sock, server_hostname=server_hostname)
    371 

/usr/lib/python3.8/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
    499         # ctx._wrap_socket()
--> 500         return self.sslsocket_class._create(
    501             sock=sock,

/usr/lib/python3.8/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
   1039                         raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
-> 1040                     self.do_handshake()
   1041             except (OSError, ValueError):

/usr/lib/python3.8/ssl.py in do_handshake(self, block)
   1308                 self.settimeout(None)
-> 1309             self._sslobj.do_handshake()
   1310         finally:

SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1108)

During handling of the above exception, another exception occurred:

MaxRetryError                             Traceback (most recent call last)
/usr/lib/python3/dist-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    438             if not chunked:
--> 439                 resp = conn.urlopen(
    440                     method=request.method,

/usr/lib/python3/dist-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    718 
--> 719             retries = retries.increment(
    720                 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]

/usr/lib/python3/dist-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
    435         if new_retry.is_exhausted():
--> 436             raise MaxRetryError(_pool, url, error or ResponseError(cause))
    437 

MaxRetryError: HTTPSConnectionPool(host='free-proxy-list.net', 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:

SSLError                                  Traceback (most recent call last)
<ipython-input-4-6de3c36938a1> in <module>
----> 1 import twitterscraper

/usr/local/lib/python3.8/dist-packages/twitterscraper/__init__.py in <module>
     11 
     12 
---> 13 from twitterscraper.query import query_tweets
     14 from twitterscraper.query import query_tweets_from_user
     15 from twitterscraper.query import query_user_info

/usr/local/lib/python3.8/dist-packages/twitterscraper/query.py in <module>
     74         yield start + h * i
     75 
---> 76 proxies = get_proxies()
     77 proxy_pool = cycle(proxies)
     78 

/usr/local/lib/python3.8/dist-packages/twitterscraper/query.py in get_proxies()
     44 
     45 def get_proxies():
---> 46     response = requests.get(PROXY_URL)
     47     soup = BeautifulSoup(response.text, 'lxml')
     48     table = soup.find('table',id='proxylisttable')

/usr/lib/python3/dist-packages/requests/api.py in get(url, params, **kwargs)
     73 
     74     kwargs.setdefault('allow_redirects', True)
---> 75     return request('get', url, params=params, **kwargs)
     76 
     77 

/usr/lib/python3/dist-packages/requests/api.py in request(method, url, **kwargs)
     58     # cases, and look like a memory leak in others.
     59     with sessions.Session() as session:
---> 60         return session.request(method=method, url=url, **kwargs)
     61 
     62 

/usr/lib/python3/dist-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    531         }
    532         send_kwargs.update(settings)
--> 533         resp = self.send(prep, **send_kwargs)
    534 
    535         return resp

/usr/lib/python3/dist-packages/requests/sessions.py in send(self, request, **kwargs)
    644 
    645         # Send the request
--> 646         r = adapter.send(request, **kwargs)
    647 
    648         # Total elapsed time of the request (approximately)

/usr/lib/python3/dist-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    512             if isinstance(e.reason, _SSLError):
    513                 # This branch is for urllib3 v1.22 and later.
--> 514                 raise SSLError(e, request=request)
    515 
    516             raise ConnectionError(e, request=request)

SSLError: HTTPSConnectionPool(host='free-proxy-list.net', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1108)')))

@fedderw
Copy link

fedderw commented Jun 24, 2022

@youssefsaqr @mysterefrank @amelksibi2019 are you still experiencing this issue?

I cannot reproduce you try this solution? psf/requests#4246 (comment)

Please ping me or start a new issue if you have further questions

This solution does not work on WSL2 Ubuntu at the very least, same problem as everyone else

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests