Connecting to a MongoDB Atlas Cluster

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Connecting to a MongoDB Atlas Cluster

Sanjay Minni
Hi

can anyone pls help me with an example of connecting to a MongoDB Atlas
cluster (their cloud service).

My Atlas cluster replica set is at the urls
    yyyy-shard-00-00.xxxxx.mongodb.net:27017
    yyyy-shard-00-01.xxxxx.mongodb.net:27017
    yyyy-shard-00-02.xxxxx.mongodb.net:27017

The MongoDB Atlas website specifies the application connectstring as

   
'mongodb+srv://<username>:<password>@yyyy.xxxxx.mongodb.net/<mydefaultdatabase>?retryWrites=true&w=majority"

I saw the doc / example on pharo-nosql/mongotalk but could not figure out in
MongoClient -

1. how to get embed the username:password in the connectstring which i feel
would be needed,
2. how to specify the default database
3. is it required to specify all three members while Mongo suggests a single
part connect string which probably must be covering the cluster

thanks
 



-----
cheers,
Sanjay
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
cheers,
Sanjay
Reply | Threaded
Open this post in threaded view
|

Re: Connecting to a MongoDB Atlas Cluster

Sanjay Minni
Hi All,

I really need some help here as I am unable to connect
Pharo to MongoDB Atlas Cluster service: http://cloud.mongodb.com.
(This service gives a free 500 MB MongoDB cluster on the cloud and
thereafter larger on subscription)

I have got stuck in my application development.

The connection is thru MongoDB (client) Drivers and the connection string
typically is given as
'mongodb+srv://<username>:<password>@yyyy.xxxxx.mongodb.net/<mydefaultdatabase>?retryWrites=true&w=majority"


Ques 1.:

  is MongoClient required ?

  though Atlas service is a cluster the manual for Atlas states
  'MongoDB drivers automatically attempt server selection following a
cluster election or failover event. By
  default, the C driver immediately raises an error if its first attempt to
select a server fails. ...'

  in any case MongoClient will probably fail in the following line at
  >>initializeWith:
  ...
  initialUrlStrings := initialUrls collect: [:each | each asMongoUrl
asMongoUrlString ].

  as
  asMongoUrl will not work with the scheme 'mongodb+srv'


Ques 2:

  Can we directly connect thru class Mongo. However the specified connect
string above would not go thru


So can someone pls help on how to connect or work around this






Sanjay Minni wrote

> Hi
>
> can anyone pls help me with an example of connecting to a MongoDB Atlas
> cluster (their cloud service).
>
> My Atlas cluster replica set is at the urls
>     yyyy-shard-00-00.xxxxx.mongodb.net:27017
>     yyyy-shard-00-01.xxxxx.mongodb.net:27017
>     yyyy-shard-00-02.xxxxx.mongodb.net:27017
>
> The MongoDB Atlas website specifies the application connectstring as
>
>    
> 'mongodb+srv://
> <username>
> :
> <password>
> @yyyy.xxxxx.mongodb.net/
> <mydefaultdatabase>
> ?retryWrites=true&w=majority"
>
> I saw the doc / example on pharo-nosql/mongotalk but could not figure out
> in
> MongoClient -
>
> 1. how to get embed the username:password in the connectstring which i
> feel
> would be needed,
> 2. how to specify the default database
> 3. is it required to specify all three members while Mongo suggests a
> single
> part connect string which probably must be covering the cluster
>
> thanks
>  
>
>
>
> -----
> cheers,
> Sanjay
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html





-----
cheers,
Sanjay
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
cheers,
Sanjay
Reply | Threaded
Open this post in threaded view
|

Re: Connecting to a MongoDB Atlas Cluster

Stéphane Ducasse
Hi 

what is the authentification protocol of this service?

S

On 25 Mar 2021, at 15:12, Sanjay Minni <[hidden email]> wrote:

Hi All,

I really need some help here as I am unable to connect
Pharo to MongoDB Atlas Cluster service: http://cloud.mongodb.com.
(This service gives a free 500 MB MongoDB cluster on the cloud and
thereafter larger on subscription)

I have got stuck in my application development.

The connection is thru MongoDB (client) Drivers and the connection string
typically is given as
'mongodb+srv://<username>:<password>@yyyy.xxxxx.mongodb.net/<mydefaultdatabase>?retryWrites=true&w=majority"


Ques 1.:

 is MongoClient required ?

 though Atlas service is a cluster the manual for Atlas states
 'MongoDB drivers automatically attempt server selection following a
cluster election or failover event. By
 default, the C driver immediately raises an error if its first attempt to
select a server fails. ...'

 in any case MongoClient will probably fail in the following line at
initializeWith:
 ...
 initialUrlStrings := initialUrls collect: [:each | each asMongoUrl
asMongoUrlString ].

 as
 asMongoUrl will not work with the scheme 'mongodb+srv'


Ques 2:

 Can we directly connect thru class Mongo. However the specified connect
string above would not go thru


So can someone pls help on how to connect or work around this






Sanjay Minni wrote
Hi

can anyone pls help me with an example of connecting to a MongoDB Atlas
cluster (their cloud service).

My Atlas cluster replica set is at the urls
   yyyy-shard-00-00.xxxxx.mongodb.net:27017
   yyyy-shard-00-01.xxxxx.mongodb.net:27017
   yyyy-shard-00-02.xxxxx.mongodb.net:27017

The MongoDB Atlas website specifies the application connectstring as


'mongodb+srv://
<username>
:
<password>
@yyyy.xxxxx.mongodb.net/
<mydefaultdatabase>
?retryWrites=true&w=majority"

I saw the doc / example on pharo-nosql/mongotalk but could not figure out
in
MongoClient -

1. how to get embed the username:password in the connectstring which i
feel
would be needed,
2. how to specify the default database
3. is it required to specify all three members while Mongo suggests a
single
part connect string which probably must be covering the cluster

thanks




-----
cheers,
Sanjay
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html





-----
cheers,
Sanjay
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

--------------------------------------------
Stéphane Ducasse
03 59 35 87 52
Assistant: Aurore Dalle 
FAX 03 59 57 78 50
TEL 03 59 35 86 16
S. Ducasse - Inria
40, avenue Halley, 
Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
Villeneuve d'Ascq 59650
France

Reply | Threaded
Open this post in threaded view
|

Re: Connecting to a MongoDB Atlas Cluster

Sanjay Minni
Thanks Stef,

I really am not technically knowledgeable to answer that question
but all documentation is here
https://docs.atlas.mongodb.com/tutorial/connect-to-your-cluster/

however after the technicals, i sort of noted somewhere that A database
username and password is required in the connect string for a connect and
there could be a slight variation in AWS / Azure / GCP hosting (I am using
GCP but can change)

Thanks for helping


Stéphane Ducasse wrote
> Hi
>
> what is the authentification protocol of this service?
>
> S
>
>> On 25 Mar 2021, at 15:12, Sanjay Minni &lt;

> sm@

> &gt; wrote:
>>
>> Hi All,
>>
>> I really need some help here as I am unable to connect
>> Pharo to MongoDB Atlas Cluster service: http://cloud.mongodb.com.
>> (This service gives a free 500 MB MongoDB cluster on the cloud and
>> thereafter larger on subscription)
>>
>> I have got stuck in my application development.
>>
>> The connection is thru MongoDB (client) Drivers and the connection string
>> typically is given as
>> 'mongodb+srv://
> <username>
> :
> <password>
> @yyyy.xxxxx.mongodb.net/
> <mydefaultdatabase>
> ?retryWrites=true&w=majority"
>>
>>
>> Ques 1.:
>>
>>  is MongoClient required ?
>>
>>  though Atlas service is a cluster the manual for Atlas states
>>  'MongoDB drivers automatically attempt server selection following a
>> cluster election or failover event. By
>>  default, the C driver immediately raises an error if its first attempt
>> to
>> select a server fails. ...'
>>
>>  in any case MongoClient will probably fail in the following line at
>>>> initializeWith:
>>  ...
>>  initialUrlStrings := initialUrls collect: [:each | each asMongoUrl
>> asMongoUrlString ].
>>
>>  as
>>  asMongoUrl will not work with the scheme 'mongodb+srv'
>>
>>
>> Ques 2:
>>
>>  Can we directly connect thru class Mongo. However the specified connect
>> string above would not go thru
>>
>>
>> So can someone pls help on how to connect or work around this
>>
>>
>>
>>
>>
>>
>> Sanjay Minni wrote
>>> Hi
>>>
>>> can anyone pls help me with an example of connecting to a MongoDB Atlas
>>> cluster (their cloud service).
>>>
>>> My Atlas cluster replica set is at the urls
>>>    yyyy-shard-00-00.xxxxx.mongodb.net:27017
>>>    yyyy-shard-00-01.xxxxx.mongodb.net:27017
>>>    yyyy-shard-00-02.xxxxx.mongodb.net:27017
>>>
>>> The MongoDB Atlas website specifies the application connectstring as
>>>
>>>
>>> 'mongodb+srv://
>>>
> <username>
>>> :
>>>
> <password>
>>> @yyyy.xxxxx.mongodb.net/
>>>
> <mydefaultdatabase>
>>> ?retryWrites=true&w=majority"
>>>
>>> I saw the doc / example on pharo-nosql/mongotalk but could not figure
>>> out
>>> in
>>> MongoClient -
>>>
>>> 1. how to get embed the username:password in the connectstring which i
>>> feel
>>> would be needed,
>>> 2. how to specify the default database
>>> 3. is it required to specify all three members while Mongo suggests a
>>> single
>>> part connect string which probably must be covering the cluster
>>>
>>> thanks
>>>
>>>
>>>
>>>
>>> -----
>>> cheers,
>>> Sanjay
>>> --
>>> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>>
>>
>>
>>
>>
>> -----
>> cheers,
>> Sanjay
>> --
>> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
> --------------------------------------------
> Stéphane Ducasse
> http://stephane.ducasse.free.fr / http://www.pharo.org 
> 03 59 35 87 52
> Assistant: Aurore Dalle
> FAX 03 59 57 78 50
> TEL 03 59 35 86 16
> S. Ducasse - Inria
> 40, avenue Halley,
> Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
> Villeneuve d'Ascq 59650
> France





-----
cheers,
Sanjay
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
cheers,
Sanjay
Reply | Threaded
Open this post in threaded view
|

Re: Connecting to a MongoDB Atlas Cluster

Long Haired David
In reply to this post by Sanjay Minni
If you are on Windows,  use curl and wire shark to see what is needed. Thats what I did to connect to RiakDB

On 18 Mar 2021 11:43, Sanjay Minni <[hidden email]> wrote:

Hi

can anyone pls help me with an example of connecting to a MongoDB Atlas
cluster (their cloud service).

My Atlas cluster replica set is at the urls
    yyyy-shard-00-00.xxxxx.mongodb.net:27017
    yyyy-shard-00-01.xxxxx.mongodb.net:27017
    yyyy-shard-00-02.xxxxx.mongodb.net:27017

The MongoDB Atlas website specifies the application connectstring as

   
'mongodb+srv://<username>:<password>@yyyy.xxxxx.mongodb.net/<mydefaultdatabase>?retryWrites=true&w=majority"

I saw the doc / example on pharo-nosql/mongotalk but could not figure out in
MongoClient -

1. how to get embed the username:password in the connectstring which i feel
would be needed,
2. how to specify the default database
3. is it required to specify all three members while Mongo suggests a single
part connect string which probably must be covering the cluster

thanks
 



-----
cheers,
Sanjay
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html


David
Totally Objects
Doing Smalltalk since 1989
Reply | Threaded
Open this post in threaded view
|

Re: Connecting to a MongoDB Atlas Cluster

Sanjay Minni
In reply to this post by Sanjay Minni
I dont know how the Pharo Mongo Driver works but if connecting to Mongo Atlas
would require a lot of exploring then could using the mongo C drivers thru
uFFI or some other way be an alternative method to connect to Mongo Atlas
 
https://docs.mongodb.com/drivers/c/

Regards



Sanjay Minni wrote

> Thanks Stef,
>
> I really am not technically knowledgeable to answer that question
> but all documentation is here
> https://docs.atlas.mongodb.com/tutorial/connect-to-your-cluster/
>
> however after the technicals, i sort of noted somewhere that A database
> username and password is required in the connect string for a connect and
> there could be a slight variation in AWS / Azure / GCP hosting (I am using
> GCP but can change)
>
> Thanks for helping
>
>
> Stéphane Ducasse wrote
>> Hi
>>
>> what is the authentification protocol of this service?
>>
>> S
>>
>>> On 25 Mar 2021, at 15:12, Sanjay Minni &lt;
>
>> sm@
>
>> &gt; wrote:
>>>
>>> Hi All,
>>>
>>> I really need some help here as I am unable to connect
>>> Pharo to MongoDB Atlas Cluster service: http://cloud.mongodb.com.
>>> (This service gives a free 500 MB MongoDB cluster on the cloud and
>>> thereafter larger on subscription)
>>>
>>> I have got stuck in my application development.
>>>
>>> The connection is thru MongoDB (client) Drivers and the connection
>>> string
>>> typically is given as
>>> 'mongodb+srv://
>>
> <username>
>> :
>>
> <password>
>> @yyyy.xxxxx.mongodb.net/
>>
> <mydefaultdatabase>
>> ?retryWrites=true&w=majority"
>>>
>>>
>>> Ques 1.:
>>>
>>>  is MongoClient required ?
>>>
>>>  though Atlas service is a cluster the manual for Atlas states
>>>  'MongoDB drivers automatically attempt server selection following a
>>> cluster election or failover event. By
>>>  default, the C driver immediately raises an error if its first attempt
>>> to
>>> select a server fails. ...'
>>>
>>>  in any case MongoClient will probably fail in the following line at
>>>>> initializeWith:
>>>  ...
>>>  initialUrlStrings := initialUrls collect: [:each | each asMongoUrl
>>> asMongoUrlString ].
>>>
>>>  as
>>>  asMongoUrl will not work with the scheme 'mongodb+srv'
>>>
>>>
>>> Ques 2:
>>>
>>>  Can we directly connect thru class Mongo. However the specified connect
>>> string above would not go thru
>>>
>>>
>>> So can someone pls help on how to connect or work around this
>>>
>>>
>>>
>>>
>>>
>>>
>>> Sanjay Minni wrote
>>>> Hi
>>>>
>>>> can anyone pls help me with an example of connecting to a MongoDB Atlas
>>>> cluster (their cloud service).
>>>>
>>>> My Atlas cluster replica set is at the urls
>>>>    yyyy-shard-00-00.xxxxx.mongodb.net:27017
>>>>    yyyy-shard-00-01.xxxxx.mongodb.net:27017
>>>>    yyyy-shard-00-02.xxxxx.mongodb.net:27017
>>>>
>>>> The MongoDB Atlas website specifies the application connectstring as
>>>>
>>>>
>>>> 'mongodb+srv://
>>>>
>>
> <username>
>>>> :
>>>>
>>
> <password>
>>>> @yyyy.xxxxx.mongodb.net/
>>>>
>>
> <mydefaultdatabase>
>>>> ?retryWrites=true&w=majority"
>>>>
>>>> I saw the doc / example on pharo-nosql/mongotalk but could not figure
>>>> out
>>>> in
>>>> MongoClient -
>>>>
>>>> 1. how to get embed the username:password in the connectstring which i
>>>> feel
>>>> would be needed,
>>>> 2. how to specify the default database
>>>> 3. is it required to specify all three members while Mongo suggests a
>>>> single
>>>> part connect string which probably must be covering the cluster
>>>>
>>>> thanks
>>>>
>>>>
>>>>
>>>>
>>>> -----
>>>> cheers,
>>>> Sanjay
>>>> --
>>>> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>>>
>>>
>>>
>>>
>>>
>>> -----
>>> cheers,
>>> Sanjay
>>> --
>>> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>>
>> --------------------------------------------
>> Stéphane Ducasse
>> http://stephane.ducasse.free.fr / http://www.pharo.org 
>> 03 59 35 87 52
>> Assistant: Aurore Dalle
>> FAX 03 59 57 78 50
>> TEL 03 59 35 86 16
>> S. Ducasse - Inria
>> 40, avenue Halley,
>> Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
>> Villeneuve d'Ascq 59650
>> France
>
>
>
>
>
> -----
> cheers,
> Sanjay
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html





-----
cheers,
Sanjay
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
cheers,
Sanjay
Reply | Threaded
Open this post in threaded view
|

Re: Connecting to a MongoDB Atlas Cluster

Sanjay Minni
In reply to this post by Sanjay Minni
Stef,

Just an addition to my previous mail on your query on protocol

Per the MongoDB-atlas control panel the following connect protocol options
are available. These come up when a database user is added thru Database
Access option
- SCRAM
- X.509 Certificate
- AWS IAM

Hope this is the information you are looking for
 




Sanjay Minni wrote

> Thanks Stef,
>
> I really am not technically knowledgeable to answer that question
> but all documentation is here
> https://docs.atlas.mongodb.com/tutorial/connect-to-your-cluster/
>
> however after the technicals, i sort of noted somewhere that A database
> username and password is required in the connect string for a connect and
> there could be a slight variation in AWS / Azure / GCP hosting (I am using
> GCP but can change)
>
> Thanks for helping
>
>
> Stéphane Ducasse wrote
>> Hi
>>
>> what is the authentification protocol of this service?
>>
>> S
>>
>>> On 25 Mar 2021, at 15:12, Sanjay Minni &lt;
>
>> sm@
>
>> &gt; wrote:
>>>
>>> Hi All,
>>>
>>> I really need some help here as I am unable to connect
>>> Pharo to MongoDB Atlas Cluster service: http://cloud.mongodb.com.
>>> (This service gives a free 500 MB MongoDB cluster on the cloud and
>>> thereafter larger on subscription)
>>>
>>> I have got stuck in my application development.
>>>
>>> The connection is thru MongoDB (client) Drivers and the connection
>>> string
>>> typically is given as
>>> 'mongodb+srv://
>>
> <username>
>> :
>>
> <password>
>> @yyyy.xxxxx.mongodb.net/
>>
> <mydefaultdatabase>
>> ?retryWrites=true&w=majority"
>>>
>>>
>>> Ques 1.:
>>>
>>>  is MongoClient required ?
>>>
>>>  though Atlas service is a cluster the manual for Atlas states
>>>  'MongoDB drivers automatically attempt server selection following a
>>> cluster election or failover event. By
>>>  default, the C driver immediately raises an error if its first attempt
>>> to
>>> select a server fails. ...'
>>>
>>>  in any case MongoClient will probably fail in the following line at
>>>>> initializeWith:
>>>  ...
>>>  initialUrlStrings := initialUrls collect: [:each | each asMongoUrl
>>> asMongoUrlString ].
>>>
>>>  as
>>>  asMongoUrl will not work with the scheme 'mongodb+srv'
>>>
>>>
>>> Ques 2:
>>>
>>>  Can we directly connect thru class Mongo. However the specified connect
>>> string above would not go thru
>>>
>>>
>>> So can someone pls help on how to connect or work around this
>>>
>>>
>>>
>>>
>>>
>>>
>>> Sanjay Minni wrote
>>>> Hi
>>>>
>>>> can anyone pls help me with an example of connecting to a MongoDB Atlas
>>>> cluster (their cloud service).
>>>>
>>>> My Atlas cluster replica set is at the urls
>>>>    yyyy-shard-00-00.xxxxx.mongodb.net:27017
>>>>    yyyy-shard-00-01.xxxxx.mongodb.net:27017
>>>>    yyyy-shard-00-02.xxxxx.mongodb.net:27017
>>>>
>>>> The MongoDB Atlas website specifies the application connectstring as
>>>>
>>>>
>>>> 'mongodb+srv://
>>>>
>>
> <username>
>>>> :
>>>>
>>
> <password>
>>>> @yyyy.xxxxx.mongodb.net/
>>>>
>>
> <mydefaultdatabase>
>>>> ?retryWrites=true&w=majority"
>>>>
>>>> I saw the doc / example on pharo-nosql/mongotalk but could not figure
>>>> out
>>>> in
>>>> MongoClient -
>>>>
>>>> 1. how to get embed the username:password in the connectstring which i
>>>> feel
>>>> would be needed,
>>>> 2. how to specify the default database
>>>> 3. is it required to specify all three members while Mongo suggests a
>>>> single
>>>> part connect string which probably must be covering the cluster
>>>>
>>>> thanks
>>>>
>>>>
>>>>
>>>>
>>>> -----
>>>> cheers,
>>>> Sanjay
>>>> --
>>>> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>>>
>>>
>>>
>>>
>>>
>>> -----
>>> cheers,
>>> Sanjay
>>> --
>>> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>>
>> --------------------------------------------
>> Stéphane Ducasse
>> http://stephane.ducasse.free.fr / http://www.pharo.org 
>> 03 59 35 87 52
>> Assistant: Aurore Dalle
>> FAX 03 59 57 78 50
>> TEL 03 59 35 86 16
>> S. Ducasse - Inria
>> 40, avenue Halley,
>> Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
>> Villeneuve d'Ascq 59650
>> France
>
>
>
>
>
> -----
> cheers,
> Sanjay
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html





-----
cheers,
Sanjay
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
cheers,
Sanjay