Local Meteor Packages, Mongo.setConnectionOptions & Mongo.setConnectionOptions is not a function error

My mongo instance with MLab keeps timing out. I tried setting options in the URI:

mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]

via docs

but Mlab is set to no WS timeout by default (I think) so I need to turn up the timeout on my meteor mongo driver. From what I’m reading in git issues and on the forum it seems the only way to configure this is with this newly added method on Mongo:

Mongo.setConnectionOptions({
	  mongos: {
	    socketOptions: {
	      connectTimeoutMS: 300000,
	      socketTimeoutMS: 300000,
	    },
	  },
	});

To configure that, you need it to have this code snippet load first. For it to load first you need to have it in a package that sits about any other packages using mongo (e.g. accounts-base). This knowledge comes from this thread:

I setup a local package but keep hitting this error:

Mongo.setConnectionOptions is not a function both local and on galaxy. I’m not familiar with meteor packages, so I’m hoping that I’m just importing Mongo wrong. I’m pretty sure my meteor version is all up to dat and that my package is listed after ‘meteor/mongo’ but before any packages that use it.

I have my local package setup as follows:

mongo-connection.js


// Write your package code here!

// Variables exported by this module can be imported by other packages and
// applications. See mongo-connection-tests.js for an example of importing.
export const name = 'mongo-connection';

// Write your package code here!
import { Mongo } from 'meteor/mongo';


Mongo.setConnectionOptions({
	  mongos: {
	    socketOptions: {
	      connectTimeoutMS: 300000,
	      socketTimeoutMS: 300000,
	    },
	  },
	});

package.js

Package.describe({
  name: 'mongo-connection',
  version: '0.0.1',
  // Brief, one-line summary of the package.
  summary: '',
  // URL to the Git repository containing the source code for this package.
  git: '',
  // By default, Meteor will default to using README.md for documentation.
  // To avoid submitting documentation, set this field to null.
  documentation: 'README.md'
});

Package.onUse(function(api) {
  api.versionsFrom('1.4.2.3');
  api.use(['mongo', 'ecmascript']);
  api.mainModule('mongo-connection.js');
});

Package.onTest(function(api) {
  api.use('ecmascript');
  api.use('tinytest');
  api.use('mongo-connection');
  api.mainModule('mongo-connection-tests.js');
});

then my .meteor packages file:

# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-base@1.0.4             # Packages every Meteor app needs to have
mobile-experience@1.0.4       # Packages for a great mobile UX
mongo@1.1.14                   # The database Meteor supports right now
mongo-connection
reactive-var@1.0.11            # Reactive variable for tracker
session@1.1.7
tracker@1.1.1                 # Meteor's client-side reactive programming library

standard-minifier-css@1.3.2   # CSS minifier run for production mode
standard-minifier-js@1.2.1    # JS minifier run for production mode
es5-shim@4.6.15                # ECMAScript 5 compatibility for older browsers.
ecmascript@0.6.1              # Enable ECMAScript2015+ syntax in app code

accounts-password@1.3.3
accounts-base@1.2.14
check@1.2.4
audit-argument-checks@1.0.7

FULL ERROR:

mongo-connection.js:11 Uncaught TypeError: Mongo.setConnectionOptions is not a function
    at meteorInstall.node_modules.meteor.mongo-connection.mongo-connection.js (mongo-connection.js:11)
    at fileEvaluate (modules-runtime.js?hash=637cb12…:191)
    at require (modules-runtime.js?hash=637cb12…:116)
    at mongo-connection.js?hash=f2fe1b1…:55
    at mongo-connection.js?hash=f2fe1b1…:61
meteorInstall.node_modules.meteor.mongo-connection.mongo-connection.js @ mongo-connection.js:11
fileEvaluate @ modules-runtime.js?hash=637cb12…:191
require @ modules-runtime.js?hash=637cb12…:116
(anonymous) @ mongo-connection.js?hash=f2fe1b1…:55
(anonymous) @ mongo-connection.js?hash=f2fe1b1…:61

Hi @a.com

Please let me know if you got any solution for the same