Dashboard container doesn't work

Hello Team,

I hope this message finds you well. Congratulations on the launch of OpenVidu version 3! I am excited about the updates and am currently in the process of deploying the new version as a single node on-premises, following the instructions from OpenVidu Single Node installation on-premises - openVidu.

However, I am encountering an issue with the dashboard container. When I initiate the deployment using the command systemctl start openvidu, the process initially runs smoothly. Unfortunately, the dashboard container does not maintain stability and restarts every 30 seconds. This repetitive restarting happens without fail—30 seconds of uptime followed by a restart.

Upon examining the logs via docker logs -f dashboard, the primary error seems to be related to a connection failure with MongoDB. Here is the pertinent log information:

2025-01-16 19:59:35.461 info:   Pinging MongoDB...
2025-01-16 20:00:05.469 error:  Error while trying to connect to MongoDB: connect ECONNREFUSED ::1:20000
{"reason":{"type":"Unknown","servers":{"localhost:20000":{"address":"localhost:20000","type":"Unknown","hosts":[],"passives":[],"arbiters":[],"tags":{},"minWireVersion":0,"maxWireVersion":0,"roundTripTime":-1,"minRoundTripTime":0,"lastUpdateTime":46050652,"lastWriteDate":0,"error":{},"topologyVersion":null,"setName":null,"setVersion":null,"electionId":null,"logicalSessionTimeoutMinutes":null,"maxMessageSizeBytes":null,"maxWriteBatchSize":null,"maxBsonObjectSize":null,"primary":null,"me":null,"$clusterTime":null,"iscryptd":false}},"stale":false,"compatible":true,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"setName":null,"maxElectionId":null,"maxSetVersion":null,"commonWireVersion":0,"logicalSessionTimeoutMinutes":null},"cause":{}}
MongoServerSelectionError: connect ECONNREFUSED ::1:20000
    at Topology.selectServer (/snapshot/backend/node_modules/mongodb/lib/sdam/topology.js:320:38)
    at async Topology._connect (/snapshot/backend/node_modules/mongodb/lib/sdam/topology.js:204:28)
    at async Topology.connect (/snapshot/backend/node_modules/mongodb/lib/sdam/topology.js:156:13)
    at async topologyConnect (/snapshot/backend/node_modules/mongodb/lib/mongo_client.js:233:17)
    at async MongoClient._connect (/snapshot/backend/node_modules/mongodb/lib/mongo_client.js:246:13)
    at async MongoClient.connect (/snapshot/backend/node_modules/mongodb/lib/mongo_client.js:171:13)
2025-01-16 20:00:05.470 error:  Shutting down OpenVidu Dashboard

Could you please assist me in resolving this issue? Any guidance on configuring MongoDB correctly or troubleshooting potential network issues that might be causing this connection refusal would be greatly appreciated.

Thank you for your support.

It looks like a network issue. Do you have IPv6 on your machine?

I think that localhost is being translated to ::1 instead of 127.0.0.1 which is causing that problem.

Can you confirm to me that changing this parameter in /opt/openvidu/config/dashboard.env fix the issue?

DATABASE_URL=mongodb://${openvidu.MONGO_ADMIN_USERNAME:?mandatory}:${openvidu.MONGO_ADMIN_PASSWORD:?mandatory}@127.0.0.1:${openvidu.MONGO_INTERNAL_PORT:?mandatory}/?replicaSet=rs0&readPreference=primaryPreferred

Simply change localhost to 127.0.0.1

Yes, IPv6 is enabled on the machine. I’ve updated the dashboard.env as requested and then restarted OpenVidu using the command systemctl restart openvidu. However, I’m still facing the same issue:

2025-01-19 06:20:41.503 error:  Error while trying to connect to MongoDB: connect ECONNREFUSED ::1:20000
{"reason":{"type":"ReplicaSetNoPrimary","servers":{"localhost:20000":{"address":"localhost:20000","type":"Unknown","hosts":[],"passives":[],"arbiters":[],"tags":{},"minWireVersion":0,"maxWireVersion":0,"roundTripTime":-1,"minRoundTripTime":0,"lastUpdateTime":256086701,"lastWriteDate":0,"error":{},"topologyVersion":null,"setName":null,"setVersion":null,"electionId":null,"logicalSessionTimeoutMinutes":null,"maxMessageSizeBytes":null,"maxWriteBatchSize":null,"maxBsonObjectSize":null,"primary":null,"me":null,"$clusterTime":null,"iscryptd":false}},"stale":false,"compatible":true,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"setName":"rs0","maxElectionId":{"$oid":"7fffffff0000000000000004"},"maxSetVersion":1,"commonWireVersion":0,"logicalSessionTimeoutMinutes":null},"cause":{}}
MongoServerSelectionError: connect ECONNREFUSED ::1:20000
    at Topology.selectServer (/snapshot/backend/node_modules/mongodb/lib/sdam/topology.js:320:38)
    at async Topology._connect (/snapshot/backend/node_modules/mongodb/lib/sdam/topology.js:204:28)
    at async Topology.connect (/snapshot/backend/node_modules/mongodb/lib/sdam/topology.js:156:13)
    at async topologyConnect (/snapshot/backend/node_modules/mongodb/lib/mongo_client.js:233:17)
    at async MongoClient._connect (/snapshot/backend/node_modules/mongodb/lib/mongo_client.js:246:13)
    at async MongoClient.connect (/snapshot/backend/node_modules/mongodb/lib/mongo_client.js:171:13)
2025-01-19 06:20:41.504 error:  Shutting down OpenVidu Dashboard

is it possbile that the issue with mongo container ?

Hello

I’ve tackled the MongoDB connection issue we were facing with OpenVidu v3. Here’s a quick rundown of what was fixed and how:

What was wrong?
Our app was having a tough time connecting to MongoDB because it was trying to use localhost which wasn’t playing nice with our configuration.

How we fixed it:

  1. Updated dashboard.env File:
    I adjusted the DATABASE_URL to make sure we’re connecting through the loopback IP address. Here’s the new setup:

    DATABASE_URL=mongodb://${openvidu.MONGO_ADMIN_USERNAME:?mandatory}:${openvidu.MONGO_ADMIN_PASSWORD:?mandatory}@127.0.0.1:${openvidu.MONGO_INTERNAL_PORT:?mandatory}/?replicaSet=rs0&readPreference=primaryPreferred
    
  2. Tweaked docker-compose.yaml:
    Switched the MONGO_LOCAL_HOST from localhost to 127.0.0.1. Now it looks like this:

    openvidu-init:
       environment:
          - MONGO_LOCAL_HOST=127.0.0.1
    

Result:
These changes have gotten us back on track with a smooth connection to MongoDB.
Thanks mr @cruizba for your kind support :grin:

2 Likes

Thanks for the heads up! It is clear that localhost is not very reliable, I think we will change to 127.0.0.1 in our deployments for this kind of local connections to avoid this problem with future users.