mongo-dart / mongo_dart

Mongo_dart: MongoDB driver for Dart programming language
https://pub.dev/packages/mongo_dart
MIT License
446 stars 98 forks source link

Initial connection time #328

Open TecbeckMacBook opened 1 year ago

TecbeckMacBook commented 1 year ago

I have used this package in my flutter app and connected my db with the following two lines:

var db = await Db.create("MY_URL");
await db.open();

These two lines are taking 10-15 seconds on average to execute which is a huge time. User waits at the splash screen for this much time because I have to show data after fetching from mongo db on the homepage of my app. What should I do to make the initial connection faster?

giorgiofran commented 1 year ago

Where are you connecting?

TecbeckMacBook commented 1 year ago

Where are you connecting?

Sorry, I didn't get your question.

giorgiofran commented 1 year ago

Are you connecting to some cloud service, like Atlas, or do you have a specific server.

TecbeckMacBook commented 1 year ago

Are you connecting to some cloud service, like Atlas, or do you have a specific server.

I am using Atlas.

giorgiofran commented 1 year ago

Free Tier?

TecbeckMacBook commented 1 year ago

Free Tier?

Yes.

giorgiofran commented 1 year ago

There were other person reporting this problem with Atlas, but I didn't get if it depends only on the Tier or if it is Atals itself.. If you try to connect locally or on a remote server created by you, the connection time is by far better.

JohnF17 commented 1 year ago

I think we could confirm which has an "issue" by running a few tests, I for one, am currently running on the free tier atlas and i have the same delay issue, not only that but I also get a random "No master connection" or "Connection lost" error messages (I'll manage to get the proper error messages next time). But I did manage to get around that by having an RX value to listen to those changes (in errors) and try to reconnect after a few seconds. But going back to the main issue:

And then I think we'd have an understanding if its a problem with Atlas itself, or the Free tier only.

DennisKragekjaer commented 3 months ago

Yes same problem here, random Connection Exception, retry after some seconds and it works. But that is making me nervous.