Atlas cluster problems

Hi,

Connecting my Atlas cluster I get:

mongo "mongodb+srv://mflix-n2e5g.mongodb.net/test" --username m220student
MongoDB shell version v3.6.6-77-ge7b3f4dbcd
Enter password:
connecting to: mongodb+srv://mflix-n2e5g.mongodb.net/test
2018-10-08T09:31:27.593+0300 I NETWORK  [thread1] Starting new replica set monitor for mflix-shard-0/mflix-shard-00-02-n2e5g.mongodb.net.:27017,mflix-shard-00-01-n2e5g.mongodb.net.:27017,mflix-shard-00-00-n2e5g.mongodb.net.:27017
2018-10-08T09:31:27.884+0300 I NETWORK  [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to mflix-shard-00-00-n2e5g.mongodb.net.:27017 (1 connections now open to mflix-shard-00-00-n2e5g.mongodb.net.:27017 with a 5 second timeout)
2018-10-08T09:31:27.884+0300 I NETWORK  [thread1] Successfully connected to mflix-shard-00-02-n2e5g.mongodb.net.:27017 (1 connections now open to mflix-shard-00-02-n2e5g.mongodb.net.:27017 with a 5 second timeout)
2018-10-08T09:31:28.089+0300 I NETWORK  [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to mflix-shard-00-01-n2e5g.mongodb.net:27017 (1 connections now open to mflix-shard-00-01-n2e5g.mongodb.net:27017 with a 5 second timeout)
2018-10-08T09:31:28.092+0300 I NETWORK  [thread1] Successfully connected to mflix-shard-00-01-n2e5g.mongodb.net.:27017 (1 connections now open to mflix-shard-00-01-n2e5g.mongodb.net.:27017 with a 5 second timeout)
2018-10-08T09:31:28.124+0300 I NETWORK  [ReplicaSetMonitor-TaskExecutor-0] changing hosts to mflix-shard-0/mflix-shard-00-00-n2e5g.mongodb.net:27017,mflix-shard-00-01-n2e5g.mongodb.net:27017,mflix-shard-00-02-n2e5g.mongodb.net:27017 from mflix-shard-0/mflix-shard-00-00-n2e5g.mongodb.net.:27017,mflix-shard-00-01-n2e5g.mongodb.net.:27017,mflix-shard-00-02-n2e5g.mongodb.net.:27017
2018-10-08T09:31:28.268+0300 I NETWORK  [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to mflix-shard-00-00-n2e5g.mongodb.net:27017 (1 connections now open to mflix-shard-00-00-n2e5g.mongodb.net:27017 with a 5 second timeout)
2018-10-08T09:31:28.276+0300 I NETWORK  [thread1] Successfully connected to mflix-shard-00-02-n2e5g.mongodb.net:27017 (1 connections now open to mflix-shard-00-02-n2e5g.mongodb.net:27017 with a 5 second timeout)
MongoDB server version: 3.6.8
Error while trying to show server startup warnings: user is not allowed to do action [getLog] on [admin.]
MongoDB Enterprise mflix-shard-0:PRIMARY>

Which I think is the reason why my migrations script fails:

python movie_last_updated_migration.py
Traceback (most recent call last):
  File "movie_last_updated_migration.py", line 32, in <module>
    for doc in cursor:
  File "C:\Users\tino\AppData\Local\Continuum\anaconda3\lib\site-packages\pymongo\cursor.py", line 1189, in next
    if len(self.__data) or self._refresh():
  File "C:\Users\tino\AppData\Local\Continuum\anaconda3\lib\site-packages\pymongo\cursor.py", line 1087, in _refresh
    self.__session = self.__collection.database.client._ensure_session()
  File "C:\Users\tino\AppData\Local\Continuum\anaconda3\lib\site-packages\pymongo\mongo_client.py", line 1558, in _ensure_session
    return self.__start_session(True, causal_consistency=False)
  File "C:\Users\tino\AppData\Local\Continuum\anaconda3\lib\site-packages\pymongo\mongo_client.py", line 1511, in __start_session
    server_session = self._get_server_session()
  File "C:\Users\tino\AppData\Local\Continuum\anaconda3\lib\site-packages\pymongo\mongo_client.py", line 1544, in _get_server_session
    return self._topology.get_server_session()
  File "C:\Users\tino\AppData\Local\Continuum\anaconda3\lib\site-packages\pymongo\topology.py", line 427, in get_server_session
    None)
  File "C:\Users\tino\AppData\Local\Continuum\anaconda3\lib\site-packages\pymongo\topology.py", line 199, in _select_servers_loop
    self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [WinError 10061] No connection could be made because the target machine actively refused it

Any help, I have set everything up according the instructions and user M220student has read/write rights for all dbs

unit tests fail for same reason:
pymongo.errors.OperationFailure: user is not allowed to do action [find] on [mflix.movies]

Hi @tinotn,

The connection to your Atlas cluster using the mongo shell works well:
mongo "mongodb+srv://mflix-n2e5g.mongodb.net/test" --username m220student ... MongoDB Enterprise mflix-shard-0:PRIMARY&gt;
What you are seeing in the screen is a bit of a verbose log messages about network replication information but you do successfully connect. The final message:
Error while trying to show server startup warnings: user is not allowed to do action [getLog] on [admin.] is just telling you that this use is not allowed to operate perform command getLog on admin database, which in this case is normal.

Your migration script:
python movie_last_updated_migration.py
is failing because it is trying to connect to localhost:27017 :

localhost:27017: [WinError 10061] No connection could be made because the target machine actively refused it

Make sure your script is correctly configured to connect to your Atlas cluster instead of the default localhost.

N.

“Make sure your script is correctly configured to connect to your Atlas cluster instead of the default localhost.” Where is this done? The URI in my .ini file points to the cluster

Hello tinotn,

In the migration file movie_last_updated_migration.py, line 17 sets the URI string:

16 # ensure you update your host information below!
17 host = "mongodb://localhost:27017"

To use your Atlas cluster, replace this string with the URI for your Atlas cluster.

I hope this helps!

Matt

Yes, finally! Don’t know how I’ve kept missing those lines. Thank you!