[GH-ISSUE #220] SysCallError after several succesful requests #114

Closed
opened 2026-02-27 23:20:53 +03:00 by kerem · 2 comments
Owner

Originally created by @JuanuMusic on GitHub (Oct 15, 2017).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/220

Hi! First of all, awesome library! It's currently helping me alot.
I'm currently having an Issue, in which I get an SSL error after several successful requests.
By successful I mean more than a thousand songs processed. At first, I thought it could be a Spotify limitation, but then, I noticed that the library already handles the Retry-After header when spotify applies the limitations.

Following is the full error output:

SysCallError                              Traceback (most recent call last)
~\Anaconda3\lib\site-packages\requests\packages\urllib3\contrib\pyopenssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname)
    437             try:
--> 438                 cnx.do_handshake()
    439             except OpenSSL.SSL.WantReadError:

~\Anaconda3\lib\site-packages\OpenSSL\SSL.py in do_handshake(self)
   1637         result = _lib.SSL_do_handshake(self._ssl)
-> 1638         self._raise_ssl_error(self._ssl, result)
   1639 

~\Anaconda3\lib\site-packages\OpenSSL\SSL.py in _raise_ssl_error(self, ssl, result)
   1370                         raise SysCallError(errno, errorcode.get(errno))
-> 1371                 raise SysCallError(-1, "Unexpected EOF")
   1372             else:

SysCallError: (-1, 'Unexpected EOF')

During handling of the above exception, another exception occurred:

SSLError                                  Traceback (most recent call last)
~\Anaconda3\lib\site-packages\requests\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)
    599                                                   body=body, headers=headers,
--> 600                                                   chunked=chunked)
    601 

~\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    344         try:
--> 345             self._validate_conn(conn)
    346         except (SocketTimeout, BaseSSLError) as e:

~\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py in _validate_conn(self, conn)
    843         if not getattr(conn, 'sock', None):  # AppEngine might not have  `.sock`
--> 844             conn.connect()
    845 

~\Anaconda3\lib\site-packages\requests\packages\urllib3\connection.py in connect(self)
    325             server_hostname=hostname,
--> 326             ssl_context=context)
    327 

~\Anaconda3\lib\site-packages\requests\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)
    324     if HAS_SNI:  # Platform-specific: OpenSSL with enabled SNI
--> 325         return context.wrap_socket(sock, server_hostname=server_hostname)
    326 

~\Anaconda3\lib\site-packages\requests\packages\urllib3\contrib\pyopenssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname)
    444             except OpenSSL.SSL.Error as e:
--> 445                 raise ssl.SSLError('bad handshake: %r' % e)
    446             break

SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",)

During handling of the above exception, another exception occurred:

SSLError                                  Traceback (most recent call last)
~\Anaconda3\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    437                     retries=self.max_retries,
--> 438                     timeout=timeout
    439                 )

~\Anaconda3\lib\site-packages\requests\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)
    629             clean_exit = False
--> 630             raise SSLError(e)
    631 

SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",)

During handling of the above exception, another exception occurred:

SSLError                                  Traceback (most recent call last)
<ipython-input-29-db0b4fc686c2> in <module>()
     19 
     20         # Busco el track
---> 21         search_isrc = sp.search(q='isrc:' + isrc, type='track')
     22 
     23         # Si tiene datos

~\Anaconda3\lib\site-packages\spotipy\client.py in search(self, q, limit, offset, type, market)
    337                 - market - An ISO 3166-1 alpha-2 country code or the string from_token.
    338         '''
--> 339         return self._get('search', q=q, limit=limit, offset=offset, type=type, market=market)
    340 
    341     def user(self, user):

~\Anaconda3\lib\site-packages\spotipy\client.py in _get(self, url, args, payload, **kwargs)
    144         while retries > 0:
    145             try:
--> 146                 return self._internal_call('GET', url, payload, kwargs)
    147             except SpotifyException as e:
    148                 retries -= 1

~\Anaconda3\lib\site-packages\spotipy\client.py in _internal_call(self, method, url, payload, params)
    106         if self.trace_out:
    107             print(url)
--> 108         r = self._session.request(method, url, headers=headers, proxies=self.proxies, **args)
    109 
    110         if self.trace:  # pragma: no cover

~\Anaconda3\lib\site-packages\requests\sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    516         }
    517         send_kwargs.update(settings)
--> 518         resp = self.send(prep, **send_kwargs)
    519 
    520         return resp

~\Anaconda3\lib\site-packages\requests\sessions.py in send(self, request, **kwargs)
    637 
    638         # Send the request
--> 639         r = adapter.send(request, **kwargs)
    640 
    641         # Total elapsed time of the request (approximately)

~\Anaconda3\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    510         except (_SSLError, _HTTPError) as e:
    511             if isinstance(e, _SSLError):
--> 512                 raise SSLError(e, request=request)
    513             elif isinstance(e, ReadTimeoutError):
    514                 raise ReadTimeout(e, request=request)

SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",)
Originally created by @JuanuMusic on GitHub (Oct 15, 2017). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/220 Hi! First of all, awesome library! It's currently helping me alot. I'm currently having an Issue, in which I get an SSL error after several successful requests. By successful I mean more than a thousand songs processed. At first, I thought it could be a Spotify limitation, but then, I noticed that the library already handles the Retry-After header when spotify applies the limitations. Following is the full error output: ``` SysCallError Traceback (most recent call last) ~\Anaconda3\lib\site-packages\requests\packages\urllib3\contrib\pyopenssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname) 437 try: --> 438 cnx.do_handshake() 439 except OpenSSL.SSL.WantReadError: ~\Anaconda3\lib\site-packages\OpenSSL\SSL.py in do_handshake(self) 1637 result = _lib.SSL_do_handshake(self._ssl) -> 1638 self._raise_ssl_error(self._ssl, result) 1639 ~\Anaconda3\lib\site-packages\OpenSSL\SSL.py in _raise_ssl_error(self, ssl, result) 1370 raise SysCallError(errno, errorcode.get(errno)) -> 1371 raise SysCallError(-1, "Unexpected EOF") 1372 else: SysCallError: (-1, 'Unexpected EOF') During handling of the above exception, another exception occurred: SSLError Traceback (most recent call last) ~\Anaconda3\lib\site-packages\requests\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) 599 body=body, headers=headers, --> 600 chunked=chunked) 601 ~\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw) 344 try: --> 345 self._validate_conn(conn) 346 except (SocketTimeout, BaseSSLError) as e: ~\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py in _validate_conn(self, conn) 843 if not getattr(conn, 'sock', None): # AppEngine might not have `.sock` --> 844 conn.connect() 845 ~\Anaconda3\lib\site-packages\requests\packages\urllib3\connection.py in connect(self) 325 server_hostname=hostname, --> 326 ssl_context=context) 327 ~\Anaconda3\lib\site-packages\requests\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) 324 if HAS_SNI: # Platform-specific: OpenSSL with enabled SNI --> 325 return context.wrap_socket(sock, server_hostname=server_hostname) 326 ~\Anaconda3\lib\site-packages\requests\packages\urllib3\contrib\pyopenssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname) 444 except OpenSSL.SSL.Error as e: --> 445 raise ssl.SSLError('bad handshake: %r' % e) 446 break SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",) During handling of the above exception, another exception occurred: SSLError Traceback (most recent call last) ~\Anaconda3\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies) 437 retries=self.max_retries, --> 438 timeout=timeout 439 ) ~\Anaconda3\lib\site-packages\requests\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) 629 clean_exit = False --> 630 raise SSLError(e) 631 SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",) During handling of the above exception, another exception occurred: SSLError Traceback (most recent call last) <ipython-input-29-db0b4fc686c2> in <module>() 19 20 # Busco el track ---> 21 search_isrc = sp.search(q='isrc:' + isrc, type='track') 22 23 # Si tiene datos ~\Anaconda3\lib\site-packages\spotipy\client.py in search(self, q, limit, offset, type, market) 337 - market - An ISO 3166-1 alpha-2 country code or the string from_token. 338 ''' --> 339 return self._get('search', q=q, limit=limit, offset=offset, type=type, market=market) 340 341 def user(self, user): ~\Anaconda3\lib\site-packages\spotipy\client.py in _get(self, url, args, payload, **kwargs) 144 while retries > 0: 145 try: --> 146 return self._internal_call('GET', url, payload, kwargs) 147 except SpotifyException as e: 148 retries -= 1 ~\Anaconda3\lib\site-packages\spotipy\client.py in _internal_call(self, method, url, payload, params) 106 if self.trace_out: 107 print(url) --> 108 r = self._session.request(method, url, headers=headers, proxies=self.proxies, **args) 109 110 if self.trace: # pragma: no cover ~\Anaconda3\lib\site-packages\requests\sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json) 516 } 517 send_kwargs.update(settings) --> 518 resp = self.send(prep, **send_kwargs) 519 520 return resp ~\Anaconda3\lib\site-packages\requests\sessions.py in send(self, request, **kwargs) 637 638 # Send the request --> 639 r = adapter.send(request, **kwargs) 640 641 # Total elapsed time of the request (approximately) ~\Anaconda3\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies) 510 except (_SSLError, _HTTPError) as e: 511 if isinstance(e, _SSLError): --> 512 raise SSLError(e, request=request) 513 elif isinstance(e, ReadTimeoutError): 514 raise ReadTimeout(e, request=request) SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",) ```
kerem closed this issue 2026-02-27 23:20:54 +03:00
Author
Owner

@JuanuMusic commented on GitHub (Oct 15, 2017):

Actually, I think I just found the problem. It was a problem with my connection, resetting.
Sorry for the inconvenience, and thanks for the hard work to everybody!

<!-- gh-comment-id:336711886 --> @JuanuMusic commented on GitHub (Oct 15, 2017): Actually, I think I just found the problem. It was a problem with my connection, resetting. Sorry for the inconvenience, and thanks for the hard work to everybody!
Author
Owner

@xueqilei commented on GitHub (Nov 1, 2017):

I meet the same problem.What is your solution? thanks for you .

<!-- gh-comment-id:341088099 --> @xueqilei commented on GitHub (Nov 1, 2017): I meet the same problem.What is your solution? thanks for you .
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#114
No description provided.