1

I am using MongoDB version 2.4.14 on a Raspberry Pi (running the latest Raspbian). I have a simple test file trying to get mongo to work:


let url = 'mongodb://172.20.0.239:27017/'
var MongoClient = require('mongodb').MongoClient;
MongoClient.connect(url,{ useUnifiedTopology: true }, function(err, db) {
    if (err) throw err;
    var dbo = db.db(<database>);

    var cursor = dbo.collection("Players").find();
    if (cursor == null) {
        console.log('cursor nulo');
    } else {
        console.log('cursor n nulo');
        var strArray = [];
        cursor.each(function (err, item) {
            if(item!=null){
                strArray.push(item.datetime+' '+item.onlineUsers);
                console.log(item.datetime+' '+item.onlineUsers);
            }
            else{
                dbo.close();
            }
        });
    }
});

I am getting the error:

MongoServerSelectionError: Server at 172.20.0.239:27017 reports maximum wire version 0, but this version of the Node.js Driver requires at least 2 (MongoDB 2.6)

Is there something wrong with my code?

woofymax
  • 11
  • 1

1 Answers1

1

Modern MongoDB drivers support MongoDB server 2.6 and newer. You are using a 2.4 server.

If possible I recommend upgrading your server to at least 2.6. If this is not possible, you need to hunt down an old (really old at this point) version of the driver that supports 2.4.

D. SM
  • 13,584
  • 3
  • 12
  • 21