-
-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
misleading error message when connection reset due to atlas free + shared cluster limitations #228
Comments
Thanks for your feedback. |
Hey guys, I just want to add that I've been having this error a lot too, and until I found this issue I also had no idea why it was (tbh I'm still not totally sure it's this). I have an application that works fine when I'm testing it alone, but when ~5 people start using it, I get this error and my mongo connections start getting refused. Is there any workaround? Also will upgrading my atlas plan to dedicated sort this problem if this is what I'm experiencing? |
Did you find any workaround ? I'm facing this issue too |
I am not even sure if I am having the same problem—for me, it seems that using I also added a /// Run this before every database attempt.
static Future<void> _ensureConnection() async {
if (!_db.isConnected) {
print('MongoDB disconnected—reconnecting...');
await _db.close();
await _db.open();
print('MongoDB reconnected');
}
} |
Well this was a while ago but I started doing something like this: Future<void> get connected async {
while (db.state == State.OPENING) {
await Future.delayed(Duration(milliseconds: 100));
}
if (db.isConnected) return;
await db.close();
await db.open();
return;
} And |
Does anyone know if the serverless tier in mongodb cloud resolves this issue ? |
When watching a mongo atlas solution, the free and shared clusters (M0, M2, M5) do not accept connections which don't timeout. This can be viewed on the mongo limitations page: https://docs.atlas.mongodb.com/reference/free-shared-limitations/#operational-limitations, then scroll down to "Cursors".
The way this manifests in mongo_dart is
noSecureRequestError
from https://github.com/mongo-dart/mongo_dart/blob/main/lib/src/network/connection.dart.This message is misleading because the request was established correctly, but it was terminated by the host for other reasons. I wasn't able to figure out what sort of feedback is available -- it doesn't appear as if the socket treats it as an error condition, but just finishes the stream. When this happens, the
onDone
code gets executed, which results in the above error message (mongo_dart/lib/src/network/connection.dart
Line 167 in a6825e7
I'm not sure what the best solution here actually is. One thought -- likely the easiest -- is to just add a line to the error message saying that an Atlas M0/M2/M5 tier cluster will terminate the connection. I don't know whether it's possible to put something in serverCapabilities for better insight or hints into why it's failing.
For my use-case, I'm either going to end up upgrading the cluster tier or just re-connect on failure. Maybe a combination.
As/if I learn more in my future experiments around this, I'll update the issue.
PS
Thank for this library!
The text was updated successfully, but these errors were encountered: