question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SSLError: ("read error: Error([('SSL routines', 'ssl3_read_n', 'unexpected eof while reading')],)",)

See original GitHub issue

Hello! Earlier today, working with gcsfs version 0.4, I was getting a lot of the error mentioned in #221. I decided to go ahead and update my installation to 69d32fbd3e1575b1b7b9bc06adf6eced09fd20f1 and subsequently I am getting the error mentioned in the title (though I realize that this may or may not be related to the fix in #226)

The code I am using is:

from scipy.io import loadmat 
import gcsfs

fs = gcsfs.GCSFileSystem(project='myprojectname')

data = np.empty((124, 11796177))

for chan in range(1, 125):
    fname = op.join(path, f'chan-{chan}', f'sub-SA_sess-20180918_chan-{chan}.mat')
    # print(f"Opening {fname}")
    with fs.open(fname) as f_chan:
        f_chan = loadmat(f_chan)
        data[chan-1] = f_chan['data'].squeeze()

Which reads 124 individual mat-files into one big local array.

The full traceback is:

---------------------------------------------------------------------------
Error                                     Traceback (most recent call last)
~/.conda/envs/l2lhub/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py in recv_into(self, *args, **kwargs)
    312         try:
--> 313             return self.connection.recv_into(*args, **kwargs)
    314         except OpenSSL.SSL.SysCallError as e:

~/.conda/envs/l2lhub/lib/python3.6/site-packages/OpenSSL/SSL.py in recv_into(self, buffer, nbytes, flags)
   1839             result = _lib.SSL_read(self._ssl, buf, nbytes)
-> 1840         self._raise_ssl_error(self._ssl, result)
   1841 

~/.conda/envs/l2lhub/lib/python3.6/site-packages/OpenSSL/SSL.py in _raise_ssl_error(self, ssl, result)
   1670         else:
-> 1671             _raise_current_error()
   1672 

~/.conda/envs/l2lhub/lib/python3.6/site-packages/OpenSSL/_util.py in exception_from_error_queue(exception_type)
     53 
---> 54     raise exception_type(errors)
     55 

Error: [('SSL routines', 'ssl3_read_n', 'unexpected eof while reading')]

During handling of the above exception, another exception occurred:

SSLError                                  Traceback (most recent call last)
<ipython-input-4-3103004a59ee> in <module>
      5     # print(f"Opening {fname}")
      6     with fs.open(fname) as f_chan:
----> 7         f_chan = loadmat(f_chan)
      8         data[chan-1] = f_chan['data'].squeeze()

~/.conda/envs/l2lhub/lib/python3.6/site-packages/scipy/io/matlab/mio.py in loadmat(file_name, mdict, appendmat, **kwargs)
    216     with _open_file_context(file_name, appendmat) as f:
    217         MR, _ = mat_reader_factory(f, **kwargs)
--> 218         matfile_dict = MR.get_variables(variable_names)
    219 
    220     if mdict is not None:

~/.conda/envs/l2lhub/lib/python3.6/site-packages/scipy/io/matlab/mio5.py in get_variables(self, variable_names)
    290                 continue
    291             try:
--> 292                 res = self.read_var_array(hdr, process)
    293             except MatReadError as err:
    294                 warnings.warn(

~/.conda/envs/l2lhub/lib/python3.6/site-packages/scipy/io/matlab/mio5.py in read_var_array(self, header, process)
    250            `process`.
    251         '''
--> 252         return self._matrix_reader.array_from_header(header, process)
    253 
    254     def get_variables(self, variable_names=None):

mio5_utils.pyx in scipy.io.matlab.mio5_utils.VarReader5.array_from_header()

mio5_utils.pyx in scipy.io.matlab.mio5_utils.VarReader5.array_from_header()

mio5_utils.pyx in scipy.io.matlab.mio5_utils.VarReader5.read_real_complex()

mio5_utils.pyx in scipy.io.matlab.mio5_utils.VarReader5.read_numeric()

mio5_utils.pyx in scipy.io.matlab.mio5_utils.VarReader5.read_element()

streams.pyx in scipy.io.matlab.streams.ZlibInputStream.read_string()

streams.pyx in scipy.io.matlab.streams.ZlibInputStream.read_into()

streams.pyx in scipy.io.matlab.streams.ZlibInputStream._fill_buffer()

~/.conda/envs/l2lhub/lib/python3.6/site-packages/fsspec/spec.py in read(self, length)
   1128             # don't even bother calling fetch
   1129             return b""
-> 1130         out = self.cache._fetch(self.loc, self.loc + length)
   1131         self.loc += len(out)
   1132         return out

~/.conda/envs/l2lhub/lib/python3.6/site-packages/fsspec/caching.py in _fetch(self, start, end)
    154             part = b""
    155         end = min(self.size, end + self.blocksize)
--> 156         self.cache = self.fetcher(start, end)  # new block replaces old
    157         self.start = start
    158         self.end = self.start + len(self.cache)

<decorator-gen-177> in _fetch_range(self, start, end)

~/.conda/envs/l2lhub/lib/python3.6/site-packages/gcsfs/core.py in _tracemethod(f, self, *args, **kwargs)
     50         logger.log(logging.DEBUG - 1, tb_io.getvalue())
     51 
---> 52     return f(self, *args, **kwargs)
     53 
     54 

~/.conda/envs/l2lhub/lib/python3.6/site-packages/gcsfs/core.py in _fetch_range(self, start, end)
   1291             head = None
   1292         try:
-> 1293             r = self.gcsfs._call("GET", self.details["mediaLink"], headers=head)
   1294             data = r.content
   1295             return data

<decorator-gen-157> in _call(self, method, path, *args, **kwargs)

~/.conda/envs/l2lhub/lib/python3.6/site-packages/gcsfs/core.py in _tracemethod(f, self, *args, **kwargs)
     50         logger.log(logging.DEBUG - 1, tb_io.getvalue())
     51 
---> 52     return f(self, *args, **kwargs)
     53 
     54 

~/.conda/envs/l2lhub/lib/python3.6/site-packages/gcsfs/core.py in _call(self, method, path, *args, **kwargs)
    532                     headers=headers,
    533                     data=data,
--> 534                     timeout=self.requests_timeout,
    535                 )
    536                 validate_response(r, path)

~/.conda/envs/l2lhub/lib/python3.6/site-packages/google/auth/transport/requests.py in request(self, method, url, data, headers, max_allowed_time, timeout, **kwargs)
    315                 headers=request_headers,
    316                 timeout=timeout,
--> 317                 **kwargs
    318             )
    319         remaining_time = guard.remaining_timeout

~/.conda/envs/l2lhub/lib/python3.6/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)
    528         }
    529         send_kwargs.update(settings)
--> 530         resp = self.send(prep, **send_kwargs)
    531 
    532         return resp

~/.conda/envs/l2lhub/lib/python3.6/site-packages/requests/sessions.py in send(self, request, **kwargs)
    681 
    682         if not stream:
--> 683             r.content
    684 
    685         return r

~/.conda/envs/l2lhub/lib/python3.6/site-packages/requests/models.py in content(self)
    827                 self._content = None
    828             else:
--> 829                 self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''
    830 
    831         self._content_consumed = True

~/.conda/envs/l2lhub/lib/python3.6/site-packages/requests/models.py in generate()
    749             if hasattr(self.raw, 'stream'):
    750                 try:
--> 751                     for chunk in self.raw.stream(chunk_size, decode_content=True):
    752                         yield chunk
    753                 except ProtocolError as e:

~/.conda/envs/l2lhub/lib/python3.6/site-packages/urllib3/response.py in stream(self, amt, decode_content)
    562         else:
    563             while not is_fp_closed(self._fp):
--> 564                 data = self.read(amt=amt, decode_content=decode_content)
    565 
    566                 if data:

~/.conda/envs/l2lhub/lib/python3.6/site-packages/urllib3/response.py in read(self, amt, decode_content, cache_content)
    505             else:
    506                 cache_content = False
--> 507                 data = self._fp.read(amt) if not fp_closed else b""
    508                 if (
    509                     amt != 0 and not data

~/.conda/envs/l2lhub/lib/python3.6/http/client.py in read(self, amt)
    457             # Amount is given, implement using readinto
    458             b = bytearray(amt)
--> 459             n = self.readinto(b)
    460             return memoryview(b)[:n].tobytes()
    461         else:

~/.conda/envs/l2lhub/lib/python3.6/http/client.py in readinto(self, b)
    501         # connection, and the user is reading more bytes than will be provided
    502         # (for example, reading in 1k chunks)
--> 503         n = self.fp.readinto(b)
    504         if not n and b:
    505             # Ideally, we would raise IncompleteRead if the content-length

~/.conda/envs/l2lhub/lib/python3.6/socket.py in readinto(self, b)
    584         while True:
    585             try:
--> 586                 return self._sock.recv_into(b)
    587             except timeout:
    588                 self._timeout_occurred = True

~/.conda/envs/l2lhub/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py in recv_into(self, *args, **kwargs)
    330         # TLS 1.3 post-handshake authentication
    331         except OpenSSL.SSL.Error as e:
--> 332             raise ssl.SSLError("read error: %r" % e)
    333 
    334     def settimeout(self, timeout):

SSLError: ("read error: Error([('SSL routines', 'ssl3_read_n', 'unexpected eof while reading')],)",)

Any thoughts? Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
martindurantcommented, Mar 26, 2020

This may have had something to do with a particular version of openSSL

On March 26, 2020 5:34:37 PM EDT, Ariel Rokem notifications@github.com wrote:

Closed #246.

– You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/dask/gcsfs/issues/246#event-3170169455

1reaction
jrbourbeaucommented, Mar 26, 2020

@arokem what version of openssl are you using? There was a recent release (version 1.1.1e) that had a breaking change which caused unexpected EOF errors to be raised.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python 3.6 Requests SSLerror "unexpected eof while reading
It seems that the error was caused by openssl version 1.1.1e. Upgrading to 1.1.1f solved the problem for me. python · ssl ·...
Read more >
Error([('SSL routines', 'ssl3_read_n', 'unexpected eof ... - GitHub
Hello! Earlier today, working with gcsfs version 0.4, I was getting a lot of the error mentioned in #221. I decided to go...
Read more >
Faraday::SSLError: SSL_read: unexpected eof while reading
A customer has reported that their user as well as other users in their group are unable to use the Import from BitBucket...
Read more >
Nginx Error: "unexpected eof while reading" - Reddit
I am getting an Nginx Error: SSL_do_handshake() failed (SSL: error:0A000126:SSL routines::unexpected eof while reading) while SSL ...
Read more >
error:14095126:SSL routines:ssl3_read_n:unexpected eof ...
After upgrading my CentOS to Stream 9 and installing PHP 8.1.x I started receiving the warning message below: Warning: file_get_contents(): SSL ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found