MongoDB atlas PrivateLink

674 views
Skip to first unread message

vasilios.t...@voiceland.gr

unread,
May 25, 2022, 8:28:20 AM5/25/22
to CGRateS
Dear Team,

I have enabled AWS PrivateLink for my mongo DB cluster atlas (https://www.mongodb.com/docs/atlas/security-private-endpoint/#port-ranges-used-for-private-endpoints)
but this method creates standard connection host string like this: pl-0-us-east-1-k45tj.mongodb.net:1024,pl-0-us-east-1-k45tj.mongodb.net:1025,pl-0-us-east-1-k45tj.mongodb.net:1026 with
different ports per hostname and I can only make CGRateS to work if I set DATADB_PORT / STORDB_PORT to one of the (1024,1025,1026) ports which is not ideal as the other ports exist for redundancy.

Is there any workaround to connect to mongodb using different port for each hostname? (yes the hostname is the same in case of private link)

Maybe its better for CGRateS to support the DNS seedlist connection (SRV) method --> mongodb+srv://cluster0-pl-0-k45tj.mongodb.net ?

I am using v0.10 for now but I can switch if this will fix this issue.

thank you in advance for your support.

Vasilios Tzanoudakis

Dan Christian Bogos

unread,
May 25, 2022, 10:40:21 AM5/25/22
to cgr...@googlegroups.com
Hi Vasilios,

Not sure if you have seen this, but we have successfully used atlas in
the past.

You can find sample configuration here:


https://github.com/cgrates/cgrates/blob/master/data/conf/samples/mongoatlas/cgrates.json#L30


Is this different than you are trying to achieve?


Thanks,

DanB


vasilios.t...@voiceland.gr

unread,
May 25, 2022, 11:11:01 AM5/25/22
to CGRateS
Hi Dan,

Yes over public internet with host uris be on the same port (like the example you sent) its working fine. 

When using privatelink mongodb host list are like this
 

the ports per host are different and not 27017 for all hosts like the default provided string.

*The privatelink feature creates a private network with your mongodb cluster and your CGRateS instance talks with the MongoDB cluster using a dedicated P2P private network and using private IPs inside that network.

I hope its more clear now.

Best Regards

Vasilios Tzanoudakis


Dan Christian Bogos

unread,
May 25, 2022, 12:10:50 PM5/25/22
to cgr...@googlegroups.com

Vasilios,

In the link I have sent you, you can specify the port for each host in the cluster.

Did u try it with different ports and it did not work, ie: was still trying to connect to default one? It should also work on v0.10, so you should not upgrade.


DanB

--
You received this message because you are subscribed to the Google Groups "CGRateS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cgrates+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cgrates/b74c4715-773f-4487-b4a0-d1a01e40b1b0n%40googlegroups.com.

vasilios.t...@voiceland.gr

unread,
May 26, 2022, 6:28:10 AM5/26/22
to CGRateS
Hi Dan,


logs:
======
2022/05/26 07:08:35 CGRateS <master> [CRITICAL] Could not configure dataDb: error parsing uri: invalid host "pl-0-eu-central-1.qgnpv.mongodb.net:1026:27017": address pl-0-eu-central-1.qgnpv.mongodb.net:1026:27017: too many colons in address exiting!
2022/05/26 07:08:35 error parsing uri: invalid host "pl-0-eu-central-1.qgnpv.mongodb.net:1026:27017": address pl-0-eu-central-1.qgnpv.mongodb.net:1026:27017: too many colons in address

Now that I am sure I will open an issue for this

thanks

Vasilios Tzanoudakis

Dan Christian Bogos

unread,
May 28, 2022, 3:53:28 AM5/28/22
to cgr...@googlegroups.com

Hi Vasilios,

In the example I have sent you, each host can have it's own port, except the last one. That one inherits the port from the db_port setting. It should work since I remember we have had this implementation in the past.


In any case, we have updated the code on v0.10 and if you put now db_port=0 in your settings, it should work with all hosts urls as you put them, ignoring now the extra db_port.


Enjoy!


DanB

On 25.05.22 17:11, vasilios.t...@voiceland.gr wrote:

vasilios.t...@voiceland.gr

unread,
May 30, 2022, 5:06:02 AM5/30/22
to CGRateS
Dear Dan,


thank you very much.

Best Regards

Vasilios Tzanoudakis

Dan Christian Bogos

unread,
May 30, 2022, 8:26:37 AM5/30/22
to cgr...@googlegroups.com

Dear Vasilios,

Happy to hear it worked! :)

The thanks should go to our colleague Adrian who did the heavy lifting ;).

Enjoy!


DanB

Reply all
Reply to author
Forward
0 new messages