Skip to content

Clean connection closure via SSL_ERROR_ZERO_RETURN incorrectly treated as fatal error #1063

@forthrin

Description

@forthrin
$ ruby -r net/http -e "pp Net::HTTP.get_response(URI('https://www.moviesubtitles.org/search.php?q=paris+new+york')).body"
/opt/homebrew/lib/ruby/gems/4.0.0/gems/openssl-4.0.2/lib/openssl/buffering.rb:213:in 'OpenSSL::SSL::SSLSocket#sysread_nonblock': SSL_read: unexpected eof while reading (OpenSSL::SSL::SSLError)

# System Version: macOS 26.5.1 (25F80)
# Model Identifier: MacBookAir10,1
# ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +PRISM [arm64-darwin25]

$ curl -vs https://www.moviesubtitles.org/search.php?q=paris+new+york | head -1
< HTTP/1.0 500 Internal Server Error
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

You're going to have to contact the ruby/OpenSSL team for help with this, the error is generated from their code. The situation seems to be the underlying openssl library is returning SSL_ERROR_ZERO_RETURN (which is an indication of a clean connection closure), but they're treating it as a fatal error. -- @nhorman @ #31615

https://github.com/ruby/openssl/blob/master/ext/openssl/ossl_ssl.c#L2015

        switch (SSL_get_error(ssl, nread)) {
          case SSL_ERROR_NONE:
            rb_str_set_len(str, nread);
            return str;
          case SSL_ERROR_ZERO_RETURN: // only reference
            if (no_exception_p(opts)) { return Qnil; }
            rb_eof_error();
          // further actions removed for brevity
          case SSL_ERROR_WANT_WRITE:
          case SSL_ERROR_WANT_READ:
          case SSL_ERROR_SYSCALL:
          default:
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions