openhab-cloud icon indicating copy to clipboard operation
openhab-cloud copied to clipboard

Silent Crash with MongoDB misconfiguration

Open JP-Ellis opened this issue 6 years ago • 0 comments

I recently installed openhab-cloud and I'm trying to use a MongoDB Atlas cluster.

I'm using node v7.10.1 and the output from terminal when running app.js is:

❯ sudo node app.js
Option polling duration is not valid. Please refer to the README.
zsh: exit 1     sudo node app.js

as for the log:

2019-06-12 08:20:35:3535 info: openHAB-cloud: Backend service is starting up...
2019-06-12 08:20:35:3535 info: openHAB-cloud: Backend logging initialized...
2019-06-12 08:20:35:3535 info: openHAB-cloud: Initializing XMPP connection to GCM
2019-06-12 08:20:35:3535 info: openHAB-cloud: Connecting ro Redis at 127.0.0.1:6379
2019-06-12 08:20:37:3737 info: openHAB-cloud: Mailer will emulate sending in development environment
2019-06-12 08:20:37:3737 info: openHAB-cloud: Trying to connect to mongodb at: mongodb://[username]:[password]@mongodb+srv://[servername].gcp.mongodb.net/openhab?poolSize=100
2019-06-12 08:20:37:3737 info: openHAB-cloud: Scheduling a statistics job (every 5 min)
2019-06-12 08:20:37:3737 info: openHAB-cloud: IFTTT is configured, app handling IFTTT capabilities...
2019-06-12 08:20:37:3737 info: openHAB-cloud: express server listening on port 3000

There are no other errors.

One thing that perhaps is the issue is the unusual mongoDB address. I've tried using [servername].gcp.mongodb.net in the configuration file but this creates the error:

2019-06-12 08:23:08:088 error: openHAB-cloud: Error while connecting from openHAB-cloud to mongodb: MongoError: getaddrinfo ENOTFOUND [servername].gcp.mongodb.net [servername].gcp.mongodb.net:27017

which is odd as I am able to connect fine from the mongo command line:

mongo "mongodb+srv://[servername].gcp.mongodb.net/openhab" --username [username]

Changing the configuration to include the mongodb+srv:// scheme removes the error message, but then results in the (likely invalid) address in the log above (though I would still expect it to produce an error message).

Note that from the command line, having mongodb:// does not work either. I have tried modifying system/mongoconnect.js to use the mongodb+srv:// scheme, but running app.js crashes silently without producing any log or any error message (and I am not familiar enough with Node.js to debug this).

JP-Ellis avatar Jun 12 '19 08:06 JP-Ellis