Skip to content

Error: Connection Timed Out #106

@arcenojackson

Description

@arcenojackson

Hi there! We have a problem running the migration commands. With "status" command, we have the response but followed by error. With other commands, we only get the error:

CONNECT ERROR: 
connection timed out
/home/developer/www/dcloud-main/node_modules/mongoose/lib/connection.js:834
  const serverSelectionError = new ServerSelectionError();

The error points to mongoose connection and with some "console.logs" I saw that it is a "connection timed out".
If I comment out the line that return the reject(error), everything works great (Mongoose version: 6.6.3)

client.connect((error) => {
      if (error) {
        console.log('CONNECT ERROR: ');
        console.log(error.message);
        return reject(error);
      }

      _setClient(_this, client, options, dbName);

      for (const db of this.otherDbs) {
        console.log('DB: ');
        console.log(db)
        _setClient(db, client, {}, db.name);
      }

      resolve(_this);
    });

Our mongo-migrate-ts config file (mongo-migrate-ts version: 1.4.0):

mongoMigrateCli({
  uri: '',
  database: '',
  migrationsDir: './migrations',
  migrationsCollection: 'changeCollections',
  useEnv: true,
  environment: {
    uriVar: 'MONGODB_URI',
    databaseVar: '',
  },
  options: {
    serverSelectionTimeoutMS: 45000,
    socketTimeoutMS: 45000,
    keepAlive: true,
    retryReads: true,
    retryWrites: true,
  },
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions