Troubleshooting MongoDB Change Streams Connection

If you are unable to connect to MongoDB using change streams, please verify the checklist below. You should use your auth DB to run the following commands. Additionally, you should have a root role in auth DB. To log in to you mongo shell refer to the command below. Ensure that you substitute contents in ‘<>’ (angle brackets).

mongo <host.com>:<port>/<database> -u <username> -p --authenticationDatabase <auth_db>
  1. Run the following command to switch to auth DB

    use <auth db>
    
  2. Change Streams is supported only in Mongo version 4.0 and above.
    Run the following command in Mongo shell.

    db.version()
    

    The expected output (This may vary if you have a higher version):

    4.0.0
    
  3. Check if featureCompatibilityVersion is set to 4.0 or above.
    Run the following command in Mongo shell.

    db.adminCommand({getParameter: "*"}).featureCompatibilityVersion.version
    

    The expected output (This may vary if you have a higher version):

    4.0
    

    If the output is less than 4.0 run the following command to set it to 4.0

    db.adminCommand({setFeatureCompatibilityVersion: "4.0"})
    
  4. Verify user has read role on both local DB and the DB intended to read. Run the following command in Mongo shell.

    db.getUser("<Hevo user>").roles
    

    The expected output:

    [{  
       "role" : "read",  
       "db" : "local"  
     }, {  
       "role" : "read",  
       "db" : "<db to replicate>"  
    }]
    
  5. Change Streams is only supported in the wiredTiger storage engine. Run the following command in mongo shell.

    db.serverStatus().storageEngine.name
    

    The expected output:

    wiredTiger
    
  6. 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 concern is enabled.

    print(db._adminCommand( {getCmdLineOpts: 1}).parsed.replication.enableMajorityReadConcern)
    

    The expected output:

    [unknown type]
    

    or

    true