Skip to content
This repository was archived by the owner on May 31, 2022. It is now read-only.
This repository was archived by the owner on May 31, 2022. It is now read-only.

Connect Error #186

Open
Open
@dahudson88

Description

@dahudson88

We are attempting to access a mongo DB via a shell as shown in your example. We are getting an error when trying to connect with the following options:

const connect = require('mongodb-connection-model').connect;
const options = {
  hostname: 'localhost',
  port: 27017,
  ssh_tunnel: 'IDENTITY_FILE',
  ssh_tunnel_hostname: 'ec2-##-###-###-###.compute-1.amazonaws.com',
  ssh_tunnel_username: 'ubuntu',
  ssh_tunnel_identity_file: ['FILE.pem'],
  mongodb_username: 'mongoUser',
  mongodb_password: '######',
  mongodb_database_name:'mongoDataBase'
};

Below is how we are calling the function

 connect(options, (e, db) => {
      if (e) {
        return console.log('E', e);
      }
      db.db('mongoDataBase').collection('myCollect').count((err2, count) => {
        console.log('counted:', err2, count);
        db.close();
      });
    }).on('status', (evt) => console.log('status:', evt));

The error message that we are getting is:

 MongoClient {
  domain: null,
  _events: {},
  _eventsCount: 0,
  _maxListeners: undefined,
  s: 
   { url: 'mongodb://mongoUser:[email protected]:29464/?readPreference=primary&authSource='mongoDataBase',
     options: { useNewUrlParser: true },
     promiseLibrary: [Function: Promise],
     dbCache: {},

When we look at the status values we get:

status: { message: 'Create SSH Tunnel', complete: true }
status: { message: 'Connect to MongoDB', pending: true }
status: { message: 'Connect to MongoDB', complete: true }

One of the concerns that I see is that thought the port in options is defined as 27017 each time I attempt to call the connect function a different port is used. (ie: 29464 as shown above). I believe that this may be the root to the problem but unsure how to resolve. Additionally we never get to the db calls that are being used. Any ideas what could be going wrong here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions