Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB C# Driver 'Cursor not found'

I have quite an intensive operation that has a MongoCursor run in a loop for a few hours (on a vb.net app running via the c# driver. I'm not too sure what causes it but I run into an exception after a while

Cursor not found

This could be because of a cursor timeout, perhaps? Is there a way I can stop it happening? If its a timeout issue how do I place a longer timeout?

like image 375
Tarang Avatar asked Dec 27 '12 11:12

Tarang


People also ask

Can you use MongoDB with C#?

By developing with C# and MongoDB together one opens up a world of possibilities. Console, window, and web applications are all possible. As are cross-platform mobile applications using the Xamarin framework.

What is a MongoDB driver?

The official MongoDB Node. js driver allows Node. js applications to connect to MongoDB and work with data. The driver features an asynchronous API which allows you to interact with MongoDB using Promises or via traditional callbacks.

Is MongoDB paid?

Is MongoDB Free? You can get started with a MongoDB developer sandbox in MongoDB Atlas for free with basic configuration options. No credit cards are required to provision a cluster, and you can use it to explore and learn more about MongoDB Atlas, the database-as-a-service platform from MongoDB.


Video Answer


1 Answers

You can disable the cursor's timeout in the C# driver by calling:

cursor.SetFlags(QueryFlags.NoCursorTimeout);

Otherwise it will be closed after 10 minutes of inactivity.

Reference

like image 55
JohnnyHK Avatar answered Sep 27 '22 23:09

JohnnyHK