Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1012

Driver fails to reconnect after SSL error

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.1.0
    • Affects Version/s: 2.0.6
    • Component/s: None
    • None
    • Environment:
      Ubuntu, Mongo 2.4.9 cluster with SSL and authentication enabled.

      In rare cases, we get an SSL error. This would not be a big issue, except that the driver then enters a state where it never manages to connect again.

      Stack trace:

      OpenSSL::SSL::SSLError SSL_read: unknown protocol:
        /opt/ruby-2.0.0-p481/lib/ruby/2.0.0/openssl/buffering.rb:54:in `sysread'
        /opt/ruby-2.0.0-p481/lib/ruby/2.0.0/openssl/buffering.rb:54:in `fill_rbuff'
        /opt/ruby-2.0.0-p481/lib/ruby/2.0.0/openssl/buffering.rb:294:in `eof?'
        mongo (2.0.6) lib/mongo/socket.rb:164:in `eof?'
        mongo (2.0.6) lib/mongo/socket.rb:61:in `alive?'
        mongo (2.0.6) lib/mongo/server/connectable.rb:93:in `ensure_connected'
        mongo (2.0.6) lib/mongo/server/connection.rb:130:in `write'
        mongo (2.0.6) lib/mongo/server/connectable.rb:66:in `block in dispatch'
        mongo (2.0.6) lib/mongo/loggable.rb:44:in `log'
        mongo (2.0.6) lib/mongo/loggable.rb:67:in `log_debug'
        mongo (2.0.6) lib/mongo/server/connectable.rb:65:in `dispatch'
        mongo (2.0.6) lib/mongo/operation/write/insert.rb:77:in `block in execute_message'
        mongo (2.0.6) lib/mongo/server/connection_pool.rb:99:in `with_connection'
        mongo (2.0.6) lib/mongo/server/context.rb:63:in `with_connection'
        mongo (2.0.6) lib/mongo/operation/write/insert.rb:76:in `execute_message'
        mongo (2.0.6) lib/mongo/operation/write/insert.rb:64:in `execute'
        mongo (2.0.6) lib/mongo/collection.rb:196:in `insert_many'
        mongo (2.0.6) lib/mongo/collection.rb:175:in `insert_one'
      

      When this happens, the driver should close the connection and open a new one. However, since #eof? is failing, it never attempts to connect again, and keeps on failing with the same error.

      A simple fix of catching OpenSSL::SSL::SSLError here should work:

      https://github.com/mongodb/mongo-ruby-driver/blob/v2.1.0.rc0/lib/mongo/socket.rb#L165

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            ralf.kistner@gmail.com Ralf Kistner
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: