Skip to content

Nightscout crash: "MongoDB connection failed! Double check the MONGODB_URI setting in Heroku" #6775

Open
@philipgo

Description

Describe the bug
Every day or so my Nightscout crashes with the error message "MongoDB connection failed! Double check the MONGODB_URI setting in Heroku."

The problem appears to be with Nightscout (or AndroidAPS??), I do not need to restart the MongoDB instance and other Nightscout instances continue to work with the same MONGODB_URI without any issues. However I do need to manually restart the Nightscout instance.

Expected behavior
Nightscout should not crash or if it does it should recover automatically.

Screenshots
NS crash

Your setup information
MongoDB self hosted on a private server, Nightscout Docker (latest dev, but same issue on master) hosted on a different private server. My uploader is AndroidAPS 2.8.1.1

Logs

nightscout_1  | DEDUPE: Devicestatus exact match
nightscout_1  | /opt/app/node_modules/mongodb/lib/utils.js:668
nightscout_1  |           throw error;
nightscout_1  |           ^
nightscout_1  |
nightscout_1  | TypeError: Cannot read property '0' of undefined
nightscout_1  |     at findResult (/opt/app/lib/server/websocket.js:414:32)
nightscout_1  |     at /opt/app/node_modules/mongodb/lib/utils.js:665:9
nightscout_1  |     at handleCallback (/opt/app/node_modules/mongodb/lib/utils.j                                                                                                                                                             s:102:55)
nightscout_1  |     at /opt/app/node_modules/mongodb/lib/cursor.js:834:20
nightscout_1  |     at /opt/app/node_modules/mongodb/lib/core/cursor.js:736:9
nightscout_1  |     at Object.callback (/opt/app/node_modules/mongodb/lib/core/c                                                                                                                                                             ursor.js:432:11)
nightscout_1  |     at Timeout._onTimeout (/opt/app/node_modules/mongodb/lib/cor                                                                                                                                                             e/sdam/topology.js:443:25)
nightscout_1  |     at listOnTimeout (internal/timers.js:554:17)
nightscout_1  |     at processTimers (internal/timers.js:497:7)
nightscout_1  | Executing startBoot
nightscout_1  | Executing checkNodeVersion
nightscout_1  | Node LTS version v14.15.3 is supported
nightscout_1  | Executing checkEnv
nightscout_1  | Executing augmentSettings
nightscout_1  | Parsing config URL from IMPORT_CONFIG failed
nightscout_1  | Executing checkSettings
nightscout_1  | Checking settings
nightscout_1  | Executing setupStorage
nightscout_1  | Setting up new connection to MongoDB
nightscout_1  | Error connecting to MongoDB: {"name":"MongoServerSelectionError"                                                                                                                                                             ,"reason":{"type":"Single","setName":null,"maxSetVersion":null,"maxElectionId":n                                                                                                                                                             ull,"servers":{},"stale":false,"compatible":true,"compatibilityError":null,"logi                                                                                                                                                             calSessionTimeoutMinutes":null,"heartbeatFrequencyMS":10000,"localThresholdMS":1                                                                                                                                                             5,"commonWireVersion":null}} - retrying in 3 sec
nightscout_1  | ERROR CONNECTING TO MONGO Error: MongoDB connection failed! Doub                                                                                                                                                             le check the MONGODB_URI setting in Heroku.
nightscout_1  |     at connect_with_retry (/opt/app/lib/storage/mongo-storage.js                                                                                                                                                             :70:28)
nightscout_1  |     at processTicksAndRejections (internal/process/task_queues.j                                                                                                                                                             s:93:5)
nightscout_1  | Mongo Storage system ready
nightscout_1  | Executing setupAuthorization
nightscout_1  | Executing setupInternals
nightscout_1  | Executing ensureIndexes
nightscout_1  | Executing setupListeners
nightscout_1  | Executing setupBridge
nightscout_1  | Executing setupMMConnect
nightscout_1  | Executing finishBoot
nightscout_1  | Boot event processing completed
nightscout_1  | Security settings: INSECURE_USE_HTTP= true , SECURE_HSTS_HEADER=                                                                                                                                                              false
nightscout_1  | Listening on port 1337 b2d084333cfc
nightscout_1  | Error connecting to MongoDB: {"name":"MongoServerSelectionError"                                                                                                                                                             ,"reason":{"type":"Single","setName":null,"maxSetVersion":null,"maxElectionId":n                                                                                                                                                             ull,"servers":{},"stale":false,"compatible":true,"compatibilityError":null,"logi                                                                                                                                                             calSessionTimeoutMinutes":null,"heartbeatFrequencyMS":10000,"localThresholdMS":1                                                                                                                                                             5,"commonWireVersion":null}} - retrying in 6 sec
nightscout_1  | Error connecting to MongoDB: {"name":"MongoServerSelectionError"                                                                                                                                                             ,"reason":{"type":"Single","setName":null,"maxSetVersion":null,"maxElectionId":n                                                                                                                                                             ull,"servers":{},"stale":false,"compatible":true,"compatibilityError":null,"logi                                                                                                                                                             calSessionTimeoutMinutes":null,"heartbeatFrequencyMS":10000,"localThresholdMS":1                                                                                                                                                             5,"commonWireVersion":null}} - retrying in 9 sec
nightscout_1  | Error connecting to MongoDB: {"name":"MongoServerSelectionError"                                                                                                                                                             ,"reason":{"type":"Single","setName":null,"maxSetVersion":null,"maxElectionId":n                                                                                                                                                             ull,"servers":{},"stale":false,"compatible":true,"compatibilityError":null,"logi                                                                                                                                                             calSessionTimeoutMinutes":null,"heartbeatFrequencyMS":10000,"localThresholdMS":1                                                                                                                                                             5,"commonWireVersion":null}} - retrying in 12 sec
nightscout_1  | Error connecting to MongoDB: {"name":"MongoServerSelectionError"                                                                                                                                                             ,"reason":{"type":"Single","setName":null,"maxSetVersion":null,"maxElectionId":n                                                                                                                                                             ull,"servers":{},"stale":false,"compatible":true,"compatibilityError":null,"logi                                                                                                                                                             calSessionTimeoutMinutes":null,"heartbeatFrequencyMS":10000,"localThresholdMS":1                                                                                                                                                             5,"commonWireVersion":null}} - retrying in 15 sec
nightscout_1  | Error connecting to MongoDB: {"name":"MongoServerSelectionError"                                                                                                                                                             ,"reason":{"type":"Single","setName":null,"maxSetVersion":null,"maxElectionId":n                                                                                                                                                             ull,"servers":{},"stale":false,"compatible":true,"compatibilityError":null,"logi                                                                                                                                                             calSessionTimeoutMinutes":null,"heartbeatFrequencyMS":10000,"localThresholdMS":1                                                                                                                                                             5,"commonWireVersion":null}} - retrying in 18 sec
nightscout_1  | Error connecting to MongoDB: {"name":"MongoServerSelectionError"                                                                                                                                                             ,"reason":{"type":"Single","setName":null,"maxSetVersion":null,"maxElectionId":n                                                                                                                                                             ull,"servers":{},"stale":false,"compatible":true,"compatibilityError":null,"logi                                                                                                                                                             calSessionTimeoutMinutes":null,"heartbeatFrequencyMS":10000,"localThresholdMS":1                                                                                                                                                             5,"commonWireVersion":null}} - retrying in 21 sec
nightscout_1  | Error connecting to MongoDB: {"name":"MongoServerSelectionError"                                                                                                                                                             ,"reason":{"type":"Single","setName":null,"maxSetVersion":null,"maxElectionId":n                                                                                                                                                             ull,"servers":{},"stale":false,"compatible":true,"compatibilityError":null,"logi                                                                                                                                                             calSessionTimeoutMinutes":null,"heartbeatFrequencyMS":10000,"localThresholdMS":1                                                                                                                                                             5,"commonWireVersion":null}} - retrying in 24 sec
nightscout_1  | Error connecting to MongoDB: {"name":"MongoServerSelectionError"                                                                                                                                                             ,"reason":{"type":"Single","setName":null,"maxSetVersion":null,"maxElectionId":n                                                                                                                                                             ull,"servers":{},"stale":false,"compatible":true,"compatibilityError":null,"logi                                                                                                                                                             calSessionTimeoutMinutes":null,"heartbeatFrequencyMS":10000,"localThresholdMS":1                                                                                                                                                             5,"commonWireVersion":null}} - retrying in 27 sec
nightscout_1  | Successfully established a connected to MongoDB
nightscout_1  | Mongo user role seems ok: [ { role: 'readWrite', db: 'nightscout'                                                                                                                                                              } ]
nightscout_1  | Mongo Storage system ready

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions