Since upgrading our Meteor app from version 3.0.1 to 3.2.2, we’ve encountered consistent deployment failures on Galaxy due to MongoDB Atlas connectivity issues.
Specifically:
- Galaxy repeatedly times out when establishing a TCP/TLS connection to our MongoDB Atlas cluster.
- The same MongoDB URI connects successfully when running locally.
- Galaxy’s IP ranges are already whitelisted in MongoDB Atlas.
- Strangely, some deployments succeed, but the vast majority fail with the same timeout error “MongoNetworkTimeoutError: connection timed out.”
Anybody knows what could be causing this?
Hello,
I was with @belfigue on the support chat, and we identified two possible causes for the MongoDB Atlas connection issue:
- IP Whitelist on Atlas: The Galaxy’s source IP might not have been correctly applied in the access rules.
- Server selection timeout: The absence of an appropriate timeout parameter in the connection string could have been affecting connection stability.
As corrective actions, Belfigue reapplied the Galaxy IP whitelist rules on Atlas and also added the parameter serverSelectionTimeoutMS=5000
to the MongoDB connection string.
The issue appears to be resolved, and we will monitor his upcoming deployments to ensure the problem does not recur.
Thank you @philippeoliveira for your help.
Unfortunately, issue isn’t fully resolved, it just stopped being a critical one. The same MongoDB connectivity error log pops up whenever deploying, but the deployment process retries the connection a couple of times and eventually succeed. Not sure what else to say, other that this is very strange and worrying.
I’ll paste the error log below in case anybody can add their two cents:
MongoNetworkTimeoutError: connection timed out
at connectionFailureError (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/src/cmap/connect.ts:475:14)
at TLSSocket.<anonymous> (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/src/cmap/connect.ts:376:37)
at Object.onceWrapper (node:events:632:28)
at TLSSocket.emit (node:events:518:28)
at TLSSocket.emit (node:domain:489:12)
at TLSSocket.Socket._onTimeout (node:net:609:8)
at listOnTimeout (node:internal/timers:594:17)
at processTimers (node:internal/timers:529:7) {
connectionGeneration: 0,
[Symbol(errorLabels)]: Set(0) {},
[cause]: undefined
}
meteor://💻app/packages/mongo.js:4479
throw new Meteor.Error("An error occurred when creating an index for collection \"".concat(self._name, ": ").concat(e.message));
^
errorClass [Error]: [An error occurred when creating an index for collection "meteor_oauth_pendingCredentials: connection timed out]
at Collection.createIndexAsync (packages/mongo/collection/methods_index.js:64:15)
at runNextTicks (node:internal/process/task_queues:65:5)
at listOnTimeout (node:internal/timers:555:9)
at processTimers (node:internal/timers:529:7)
at init (packages/oauth/pending_credentials.js:21:3) {
isClientSafe: true,
error: 'An error occurred when creating an index for collection "meteor_oauth_pendingCredentials: connection timed out',
reason: undefined,
details: undefined,
errorType: 'Meteor.Error'
}
Node.js v22.14.0
Hey there, I use Atlas but not from Galaxy. Could you share your connection options.
Here are mine and I never had any issues:
const options = '?retryWrites=true' +
'&maxIdleTimeMS=5000' +
'&maxPoolSize=30' +
'&readConcernLevel=majority' +
'&readPreference=secondaryPreferred' +
'&w=majority' +
'&heartbeatFrequencyMS=15000'
1 Like
@belfigue made some deployments this morning without the serverSelectionTimeoutMS=5000 parameter and it seems that they were all successful, we will monitor the next ones to see if any errors will occur.
We suspect that this problem is actually the IP Whitelist that was somehow not applied in Atlas.