Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoDB connection error - Failed to handshake #88

Open
khalidelborai opened this issue Jan 9, 2024 · 4 comments
Open

MongoDB connection error - Failed to handshake #88

khalidelborai opened this issue Jan 9, 2024 · 4 comments
Labels

Comments

@khalidelborai
Copy link

khalidelborai commented Jan 9, 2024

Logstash information:

Please include the following information:

  1. Logstash version (e.g. bin/logstash --version)
    logstash 8.11.3
  2. Logstash installation source (e.g. built from source, with a package manager: DEB/RPM, expanded from tar or zip archive, docker)
    DEB
  3. How is Logstash being run (e.g. as a service/service manager: systemd, upstart, etc. Via command line, docker/kubernetes)
  4. How was the Logstash Plugin installed

JVM (e.g. java -version):

If the affected version of Logstash is 7.9 (or earlier), or if it is NOT using the bundled JDK or using the 'no-jdk' version in 7.10 (or higher), please provide the following information:

  1. JVM version (java -version)
  2. JVM installation source (e.g. from the Operating System's package manager, from source, etc).
  3. Value of the JAVA_HOME environment variable if set.

OS version (uname -a if on a Unix-like system):

Description of the problem including expected versus actual behavior:

Steps to reproduce:

Please include a minimal but complete recreation of the problem,
including (e.g.) pipeline definition(s), settings, locale, etc. The easier
you make for us to reproduce it, the more likely that somebody will take the
time to look at it.

  1. bin/logstash -f config.conf
output {
   mongodb {
       uri => "mongodb://user:****@127.0.0.1:27018"
       database => "database"
       collection => "collection"
   }
}

Provide logs (if relevant):

[WARN ] 2024-01-09 21:00:53.248 [Ruby-0-Thread-10: /usr/share/logstash/vendor/bundle/jruby/3.1.0/gems/mongo-2.19.3/lib/mongo/background_thread.rb:112] mongodb - MONGODB | Failed to handshake with 127.0.0.1:27018: ArgumentError: wrong number of arguments (given 2, expected 1)
[WARN ] 2024-01-09 21:00:53.249 [Ruby-0-Thread-10: /usr/share/logstash/vendor/bundle/jruby/3.1.0/gems/mongo-2.19.3/lib/mongo/background_thread.rb:112] mongodb - MONGODB | Error checking 127.0.0.1:27018: ArgumentError: wrong number of arguments (given 2, expected 1)
[WARN ] 2024-01-09 21:00:53.754 [Ruby-0-Thread-10: /usr/share/logstash/vendor/bundle/jruby/3.1.0/gems/mongo-2.19.3/lib/mongo/background_thread.rb:112] mongodb - MONGODB | Failed to handshake with 127.0.0.1:27018: ArgumentError: wrong number of arguments (given 2, expected 1)
[WARN ] 2024-01-09 21:00:53.754 [Ruby-0-Thread-10: /usr/share/logstash/vendor/bundle/jruby/3.1.0/gems/mongo-2.19.3/lib/mongo/background_thread.rb:112] mongodb - MONGODB | Error checking 127.0.0.1:27018: ArgumentError: wrong number of arguments (given 2, expected 1)
@khalidelborai
Copy link
Author

#80

@khalidelborai
Copy link
Author

Latest Version

@khalidelborai
Copy link
Author

require "mongo"
require 'rubygems'
mongo_gem_version = Gem.loaded_specs["mongo"].version

puts "MongoDB output plugin gem version", :gem_version => mongo_gem_version.to_s
client = Mongo::Client.new('mongodb://user:****@127.0.0.1:27018')

@db = client.use('database')

# Get a collection

collection = @db['collection']



# Create an array of documents to insert in bulk
documents = [
  { name: 'Document 1', value: 10 },
  { name: 'Document 2', value: 20 },
  { name: 'Document 3', value: 30 }
  # Add more documents as needed
]

# Perform the bulk insert
result = collection.insert_many(documents)

# Print the result
puts "Inserted #{result.inserted_count} documents."

# Close the MongoDB connection
client.close

MongoDB output plugin gem version
{:gem_version=>"2.19.3"}
Inserted 3 documents.

vitalik-dj added a commit to vitalik-dj/logstash-output-mongodb that referenced this issue Apr 19, 2024
@vitalik-dj
Copy link

The fix is here
#89

vitalik-dj added a commit to vitalik-dj/logstash-output-mongodb that referenced this issue Apr 22, 2024
Fix logstash-plugins#88 failed to handshake error and publish version 3.1.8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants