Troubleshooting MongoDB Change Streams Connection
Error
If you are unable to connect to MongoDB using change streams, please verify the checklist below. You must use your auth DB to run the following commands. Additionally, you must have a root role in auth DB.
Use the following command to log in to you mongo shell. Ensure that you substitute the variables in ‘<>’ (angle brackets) with the actual values.
mongo <host.com>:<port>/<database> -u <username> -p --authenticationDatabase <auth_db>
Run the following command to switch to auth DB:
```shell
use <auth db>
```
-
Change Streams is supported only in MongoDB version 4.0 and above.
Run the following command in the mongo shell:db.version()The expected output (This may vary if you have a higher version):
4.0.0 -
Check if
featureCompatibilityVersionis set to 4.0 or above.
Run the following command in Mongo shell.db.adminCommand({getParameter: "*"}).featureCompatibilityVersion.versionThe expected output (This may vary if you have a higher version):
4.0If the output is less than 4.0, run the following command to set it to 4.0
db.adminCommand({setFeatureCompatibilityVersion: "4.0"}) -
Verify that the user has
readrole on both local DB and the DB intended to read. Run the following command in Mongo shell.db.getUser("<Hevo user>").rolesThe expected output:
[{ "role" : "read", "db" : "local" }, { "role" : "read", "db" : "<db to replicate>" }] -
Change Streams is only supported in the wiredTiger storage engine. Run the following command in Mongo shell.
db.serverStatus().storageEngine.nameThe expected output:
wiredTiger -
Change Streams is supported only when majority read concern is enabled. Run the following command. If there is no output or the output is true, it means that the
majority read concernoption is enabled.print(db._adminCommand( {getCmdLineOpts: 1}).parsed.replication.enableMajorityReadConcern)The expected output:
[unknown type]or
true