Closed F-Amaral closed 4 years ago
We are having the same exact issue as described above, unfortunately also I cannot get more information to share, as the exception doesn't tell much
Hi,
I'm currently on holiday. Did you try to bypass the connection check?
On Mon, 15 Jul 2019, 12:23 Matteo, notifications@github.com wrote:
We are having the same exact issue as described above, unfortunately also I cannot get more information to share, as the exception doesn't tell much
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sergeyzwezdin/Hangfire.Mongo/issues/195?email_source=notifications&email_token=ADC6URLFCM3EANZQJXFR7PTP7RF2NA5CNFSM4IBVN35KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ5I7PA#issuecomment-511348668, or mute the thread https://github.com/notifications/unsubscribe-auth/ADC6URNZPTE6R42DWY27I6DP7RF2NANCNFSM4IBVN35A .
hello @gottscj, by bypassing the check the connection is then ok. I cloned the repo and I'll try to see what it is about
have good holidays!
Ok, it's just the cancellationToken that is too short, as it's set to 1 second. MongoAtlas in some situations can reply to a ping after 1 second, hence the command gets cancelled, throwing the exception
MongoConnectException(_dbContext, CreateObscuredConnectionString(), e);
On MongoStorage.cs:75 maybe the timeout for the cancellationToken should be configurable?
@uublive Did increasing the timeout solved it for you? For me it didn't matter if it was 1 or 5 or 10, the command still got cancelled in about 1 second. If I connected to atlas with MongoDB Compass, it connected just fine.
Yes, as a test i increased it to 5 seconds and it went through. I'm still keeping the check disabled though. I think you can safely disabled the check, as it's just a { ping } command anyway
On 16/07/2019 16:10:37, Felipe Amaral notifications@github.com wrote: @uublive [https://github.com/uublive] Did increasing the timeout solved it for you? For me it didn't matter if it was 1 or 5 or 10, the command still got cancelled in less about 1 second. If I connected to atlas with MongoDB Compass, it connected just fine. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [https://github.com/sergeyzwezdin/Hangfire.Mongo/issues/195?email_source=notifications&email_token=AAOCW7LLWQWXU7V3FVBQNNTP7XJF3A5CNFSM4IBVN35KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2A7HAQ#issuecomment-511832962], or mute the thread [https://github.com/notifications/unsubscribe-auth/AAOCW7JTYGJZ436DEVK4TFDP7XJF3ANCNFSM4IBVN35A].
Same issue here. I have disabled the ping, for the time being.
@F-Amaral,
I increased the timeout to 5 seconds and made the timeout configurable. Please let me konw if this sovles your issue. :)
closing
Hello, So I'm using a remote mongoDB Atlas service to host my mongo cluster, and the connection string is in this format:
mongodb+srv://user:pass@cluster-id.mongodb.net/database?retryWrites=true&w=majority.
I have tried using multiple variations of it within the UseMongoClient method, and it does goes fine up to the CheckConnection method, where it throws a ThrowOperationCancelledException, when reaching this piece of code on the MongoStorage class:
try { _dbContext.Database.RunCommand((Command<BsonDocument>)"{ping:1}", cancellationToken: cts.Token); } catch (Exception e) { throw new MongoConnectException(_dbContext, CreateObscuredConnectionString(), e); }
The exception message is not very descriptive, just says:
Here is the exception stack trace:
at System.Threading.CancellationToken.ThrowOperationCanceledException() at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask) at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChanged(IServerSelector selector, ClusterDescription description, Task descriptionChangedTask, TimeSpan timeout, CancellationToken cancellationToken) at MongoDB.Driver.Core.Clusters.Cluster.SelectServer(IServerSelector selector, CancellationToken cancellationToken) at MongoDB.Driver.MongoClient.AreSessionsSupportedAfterServerSelection(CancellationToken cancellationToken) at MongoDB.Driver.MongoClient.AreSessionsSupported(CancellationToken cancellationToken) at MongoDB.Driver.OperationExecutor.StartImplicitSession(CancellationToken cancellationToken) at MongoDB.Driver.MongoDatabaseImpl.UsingImplicitSession[TResult](Func
2 func, CancellationToken cancellationToken) at MongoDB.Driver.MongoDatabaseImpl.RunCommand[TResult](Command1 command, ReadPreference readPreference, CancellationToken cancellationToken) at Hangfire.Mongo.MongoStorage.CheckConnection() in D:\Users\Felipe\Documents\Source\Repos\Hangfire.Mongo\src\Hangfire.Mongo\MongoStorage.cs:line 79
It'd be awesome if somebody could help shed a light on this. Thank you!