Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with APOS_MONGODB_URI Setting for Replica Set Connection #4659

Open
rredaelli opened this issue Jul 26, 2024 · 0 comments
Open

Issue with APOS_MONGODB_URI Setting for Replica Set Connection #4659

rredaelli opened this issue Jul 26, 2024 · 0 comments
Labels

Comments

@rredaelli
Copy link

Hi,
I am experiencing an issue when setting the APOS_MONGODB_URI environment variable with a connection string for a MongoDB replica set. Despite following the correct format, the connection does not work and throws an error.

Here is the value I am using for APOS_MONGODB_URI:
APOS_MONGODB_URI=mongodb://XXXXXXXXXX:[email protected]:27017,XXX.XXX.XX.X:27017,XXX.XXX.XX.X:27017/DB_NAME?w=majority&retryWrites=true&replicaSet=rs_p20_coll&authSource=admin

Below is the error message that I am encountering:

TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:405:5)
    at new URL (node:internal/url:637:13)
    at module.exports (/opt/stagecoach/apps/p20_cultura/deployments/2024-07-25-17-17-47/node_modules/apostrophe/lib/mongodb-connect.js:19:18)
    at Object.connectToMongo (/opt/stagecoach/apps/p20_cultura/deployments/2024-07-25-17-17-47/node_modules/apostrophe/modules/@apostrophecms/db/index.js:120:36)
    at Object.init (/opt/stagecoach/apps/p20_cultura/deployments/2024-07-25-17-17-47/node_modules/apostrophe/modules/@apostrophecms/db/index.js:60:16)
    at self.create (/opt/stagecoach/apps/p20_cultura/deployments/2024-07-25-17-17-47/node_modules/apostrophe/lib/moog.js:294:20)
    at async instantiateModules (/opt/stagecoach/apps/p20_cultura/deployments/2024-07-25-17-17-47/node_modules/apostrophe/index.js:590:22)
    at async apostrophe (/opt/stagecoach/apps/p20_cultura/deployments/2024-07-25-17-17-47/node_modules/apostrophe/index.js:298:5)
    at async /opt/stagecoach/apps/p20_cultura/deployments/2024-07-25-17-17-47/node_modules/apostrophe/index.js:157:17
    at async module.exports (/opt/stagecoach/apps/p20_cultura/deployments/2024-07-25-17-17-47/node_modules/apostrophe/index.js:156:16) {
  input: 'mongodb://XXXXXXXXXX:[email protected]:27017,XXX.XXX.XX.X:27017,XXX.XXX.XX.X:27017/DB_NAME?w=majority&retryWrites=true&replicaSet=rs_p20_coll&authSource=admin',
  code: 'ERR_INVALID_URL'
}

It seems that the URL is not being parsed correctly, resulting in the ERR_INVALID_URL error. I've verified that the credentials, IP addresses, and other parameters are correct.

Could you please assist in identifying the issue or provide guidance on the correct configuration for connecting to a MongoDB replica set using APOS_MONGODB_URI?
For info: I am on Apostrophe v3.67.0.

Thank you for your help!

@rredaelli rredaelli added the bug label Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant