question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Operation Cancelled on CheckConnection

See original GitHub issue

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:

The operation was canceled.

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](Func2 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!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
uublivecommented, Jul 16, 2019

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?

0reactions
gottscjcommented, Nov 7, 2019

closing

Read more comments on GitHub >

github_iconTop Results From Across the Web

Operation Cancelled on CheckConnection · Issue #195
Hello, So I'm using a remote mongoDB Atlas service to host my mongo cluster, and the connection string is in this format:.
Read more >
[Need Help] Connect Error: "operation cancelled"
Try to ping the domain and make sure you get an IP back. Try the telnet command in the terminal "telnet xmrvsbeast.com 4242"...
Read more >
"800703fa Illegal operation attempted on a registry key" error
This problem typically occurs after an administrator uses a service account to log on to the server for an interactive session, and then...
Read more >
Connection Troubleshooting — Go
This page addresses only connection issues. If you encounter any other issues with MongoDB or the driver, visit the following resources:.
Read more >
Boost.Asio: Operation Cancelled on async_read
Operation cancelled (operation_aborted error code) is sent when the socket is closed or cancelled. Most likely your connection is somehow ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found