Method: Mongo::Client#reconnect

Defined in:
lib/mongo/client.rb

#reconnecttrue

Reconnect the client.

Examples:

Reconnect the client.

client.reconnect

Returns:

  • (true)

    Always true.

Since:

  • 2.1.0



911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
# File 'lib/mongo/client.rb', line 911

def reconnect
  addresses = cluster.addresses.map(&:to_s)

  @connect_lock.synchronize do
    do_close rescue nil

    @cluster = Cluster.new(addresses, monitoring, cluster_options)

    if @options[:auto_encryption_options]
      build_encrypter
    end

    @closed = false
  end

  true
end