Method: Mongo::Server::Monitor::Connection#handshake!
- Defined in:
- lib/mongo/server/monitor/connection.rb
#handshake! ⇒ BSON::Document
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Send handshake command to connected host and validate the response.
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/mongo/server/monitor/connection.rb', line 197 def handshake! command = handshake_command( handshake_document( @app_metadata, server_api: [:server_api] ) ) payload = command.serialize.to_s = dispatch_bytes(payload) result = Operation::Result.new() result.validate! reply = result.documents.first set_compressor!(reply) set_hello_ok!(reply) @server_connection_id = reply['connectionId'] reply rescue => exc msg = "Failed to handshake with #{address}" Utils.warn_bg_exception(msg, exc, logger: [:logger], log_prefix: [:log_prefix], bg_error_backtrace: [:bg_error_backtrace], ) raise end |