Git Product home page Git Product logo

Comments (7)

flolu avatar flolu commented on August 14, 2024 2

So today I've tried to isolate the issue by creating a minimal reproduction. It turned out, that everything works fine.
Honestly, I don't know where the issue was, but now it works 🤣

You can check it out here: https://github.com/flolu/mongodb-k8s-connection

from mongodb-kubernetes-operator.

flolu avatar flolu commented on August 14, 2024 1

@StMarian Yes. I've deployed it into the mongodb namespace, but nevertheless I get the error mentioned above.

from mongodb-kubernetes-operator.

StMarian avatar StMarian commented on August 14, 2024

I think the problem is in your connection string:
mongodb://event-store-svc.mongodb.svc.cluster.local:27017 - this is the format of the connection string to the single instance of mongodb
if you want to connect to the replicaset, your connection string should look like this:
mongodb://event-store-0.event-store-svc.mongodb.svc.cluster.local:27017,event-store-1.event-store-svc.mongodb.svc.cluster.local:27017/?replicaSet=event-store

source: https://docs.mongodb.com/manual/reference/connection-string/#replica-set-option
k8s pod dns name: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#a-aaaa-records-1

from mongodb-kubernetes-operator.

flolu avatar flolu commented on August 14, 2024

@StMarian I've tried the new connection string, but unfortunately, I still get this error:

MongoServerSelectionError: connect ECONNREFUSED 10.1.74.34:27017
    at Timeout._onTimeout (node_modules/mongodb/lib/core/sdam/topology.js:430:30)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)

Do you have any other idea, what might be the reason for this error?

from mongodb-kubernetes-operator.

jameszhengruiqing avatar jameszhengruiqing commented on August 14, 2024

@StMarian I also face the same issue.

I tried with

mongodb://example-mongodb-0.example-mongodb-svc.mongodb.svc.cluster.local:27017,example-mongodb-1.example-mongodb-svc.mongodb.svc.cluster.local:27017/?replicaSet=example-mongodb

Error log:
node:1) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [example-mongodb-1.example-mongodb-svc.mongodb.svc.cluster.local:27017] on first connect [Error: getaddrinfo ENOTFOUND example-mongodb-1.example-mongodb-svc.mongodb.svc.cluster.local at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26) { name: 'MongoNetworkError', [Symbol(mongoErrorContextSymbol)]: {} }] at Pool.<anonymous> (/app/node_modules/mongodb/lib/core/topologies/server.js:433:11) at Pool.emit (events.js:315:20) at /app/node_modules/mongodb/lib/core/connection/pool.js:577:14 at /app/node_modules/mongodb/lib/core/connection/pool.js:1021:9 at /app/node_modules/mongodb/lib/core/connection/connect.js:31:7 at callback (/app/node_modules/mongodb/lib/core/connection/connect.js:247:5) at Socket.<anonymous> (/app/node_modules/mongodb/lib/core/connection/connect.js:276:7) at Object.onceWrapper (events.js:422:26) at Socket.emit (events.js:315:20) at emitErrorNT (internal/streams/destroy.js:84:8)

from mongodb-kubernetes-operator.

StMarian avatar StMarian commented on August 14, 2024

@flolu, @jamesbroadhead the connection string that I provided assumes that the mongodb is deployed to the mongodb namespace. If this is not true, you will need to update the connection string and use the correct namespace:
mongodb://event-store-0.event-store-svc.mongodb.svc.cluster.local:27017,event-store-1.event-store-svc.mongodb.svc.cluster.local:27017/?replicaSet=event-store

from mongodb-kubernetes-operator.

jameszhengruiqing avatar jameszhengruiqing commented on August 14, 2024

I guess the issue is with the connection string. Hope this can be documented in the readme file. Thanks in advance.

from mongodb-kubernetes-operator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.