-
-
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
MongoDB ConnectionException SocketException #377
Comments
No idea. To which kind of server are you connecting to? Did you get a look on the internet about similar problems in flutter? |
Hi again. I’m using mondodb Atlas. I had to code some retry mechanism but it seems a bit weird to me that I need to do that. |
Give a look to issue #328 . |
I also noticed this. I created a script that migrated data from mysql to mongodb, Mysql was on the same machine, but mongo was on atlas and it is a serverless instance. I would say that every 5 to 10 min I got this error and I needed to restart the script. I had to handle it by creating a function: Future<T> persistentMongoOperation<T>(Future<T> Function() func) async {
for (var i = 0; i < 2; i++) {
try {
var r = await func();
return r;
} on ConnectionException {
logger.error('Connection exception: Retrying...');
await Future.delayed(Duration(seconds: 2));
await closeMongoConnection();
}
}
throw Exception('Failed to process operation');
} Where func is a method that is smart enough to cache the mongo connection and open the connection if not already. Anyway, the thing is, the nodejs driver for mongodb has a retry option under retryWrites and retryReads fields. Its not clear if these options are able to be passed in the connection string. That, I did not test. But if not, that would be a great thing to add in the dart package here. |
Hi, in my Flutter project I keep getting this:
MongoDB ConnectionException: connection closed: SocketException: Connection reset by peer (OS Error: Connection reset by peer, errno = 54)
Almost like every 5 min. Then when trying to call again, it works.
Its happening on iOS, both in simulator and on device. Does anyone know why that is popping up.
The text was updated successfully, but these errors were encountered: