Is there a way to debug why a watched collection is not returning any change stream document when iterating through the change stream cursor using the .net/C# driver? I’m not receiving any exception, and the code just keeps iterating through the batches of documents(MoveNext()
) without any document in those batches (cursor.Current.Count()
).
Prior to posting here, I checked if I could watch the exact same collection using mongoDB shell(mongosh), and I was able to successfully receive the update notifications.
I’m using the exact same user to perform the watch from .net/C# and mongosh
Following is a sample C# code used to test :
var var _cursor = _collection.Watch()
var updateResult = await _collection.UpdateOneAsync(filter, updateBuilder.Combine(updateList));
while (_cursor.MoveNext() && _cursor.Current.Count() == 0)
{
foreach (var item in _cursor.Current)
{
Console.WriteLine("Hello!");
Console.WriteLine(item);
}
}
_cursor.dispose();
return updateResult.ModifiedCount == 1;