[CSHARP-2206] Watch method fails when c# driver upgraded to 2.5 from 2.4 Created: 07/Mar/18  Updated: 27/Oct/23  Resolved: 07/Mar/18

Status: Closed
Project: C# Driver
Component/s: API, Operations
Affects Version/s: 2.5
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Puneet Sharma Assignee: Robert Stam
Resolution: Works as Designed Votes: 0
Labels: driver, question
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 10, Core i3 with 8GB RAM using Visual studio 2015 professional.



 Description   

Just after upgrading the c# driver to 2.5, my logic where I am using watch method to check for any updates on collection started failing with an error message.

GetRequestChanges method failed with error : Command aggregate failed: Unrecognized pipeline stage name: '$changeStream'

below is the code: and last line is where code breaks.
{{var db = ConnectMongoDB();
var options = new ChangeStreamOptions

{ FullDocument = ChangeStreamFullDocumentOption.UpdateLookup }

;
var pipeline = new EmptyPipelineDefinition<ChangeStreamDocument<BsonDocument>>().Match(Builders<ChangeStreamDocument<BsonDocument>>.Filter.Empty);
var col = db.GetCollection<BsonDocument>("tblRequest");
var cursor = col.Watch(pipeline, options);}}

In documentation, I do see the very first point says

The 2.5.0 driver adds support for many of the new features introduced by the 3.6.0 server.

Change streams
The 2.5.0 driver adds support for change streams. See the Watch and WatchAsync methods in IMongoCollection.

but here I don't see anything that suggests any changes.

Can you suggest what's wrong here?



 Comments   
Comment by Robert Stam [ 07/Mar/18 ]

OK. Thanks for letting me know that.

Comment by Puneet Sharma [ 07/Mar/18 ]

It seems like it was my mistake, my API was configured with a server which was having MongoDB 3.6 and my client-side application was configured with a server having 3.4 MongoDB. Hence the issue.
I believe you can close this issue.

Comment by Robert Stam [ 07/Mar/18 ]

The error message:

Unrecognized pipeline stage name: '$changeStream'

is being returned from the server.

The first two things you should look into are:

1. Is the server version 3.6? (older versions don't support change streams)
2. Is the server deployment a replica set or a sharded cluster? (standalone servers don't support change streams)

Generated at Wed Feb 07 21:41:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.