Openhab-Cloud & MongoDB Auth Problem

Hello,
i have installed the Openhab-Cloud on my server so far it is up and running but i can’t register an Account and get the following error:

(node:25005) UnhandledPromiseRejectionWarning: MongoError: command count requires authentication
    at Connection.<anonymous> (/var/www/vhosts/siam-online.de/openhab.siam-online.de/openhab-cloud/node_modules/mongoose/node_modules/mongodb/lib/core/connection/pool.js:454:61)
    at emitTwo (events.js:126:13)
    at Connection.emit (events.js:214:7)
    at processMessage (/var/www/vhosts/siam-online.de/openhab.siam-online.de/openhab-cloud/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connection.js:368:10)
    at Socket.<anonymous> (/var/www/vhosts/siam-online.de/openhab.siam-online.de/openhab-cloud/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connection.js:537:15)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:607:20)
(node:25005) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 25)

if i try to login :

[root@s22930247 openhab-cloud]# node app.js
Option polling duration is not valid. Please refer to the README.
(node:25005) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
(node:25005) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
(node:25005) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
MongoError: command find requires authentication
    at Connection.<anonymous> (/var/www/vhosts/siam-online.de/openhab.siam-online.de/openhab-cloud/node_modules/mongoose/node_modules/mongodb/lib/core/connection/pool.js:454:61)
    at emitTwo (events.js:126:13)
    at Connection.emit (events.js:214:7)
    at processMessage (/var/www/vhosts/siam-online.de/openhab.siam-online.de/openhab-cloud/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connection.js:368:10)
    at Socket.<anonymous> (/var/www/vhosts/siam-online.de/openhab.siam-online.de/openhab-cloud/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connection.js:537:15)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:607:20)

The mongodb is up and running and the account for openhab-cloud is ready and i can login to the database.

here is my config.json:

{
    "system": {
      "host": "openhab.siam-online.de",
      "port": "443",
      "protocol": "https",
      "logger" : {
        "dir": "./logs",
        "maxFiles" : "7d",
        "level" : "debug",
        "morganOption" : null
      },
      "subDomainCookies": false,
      "muteNotifications": false
    },
    "express":{
      "key" : "some express key"
    },
    "apn" : {
      "gateway": "gateway.push.apple.com",
      "cert": "certs/aps/aps_production_cert.pem",
      "key": "certs/aps/aps_production_key.pem",
      "passphrase": "passphrase"
    },
    "gcm" : {
      "jid": "++removed++",
      "password": "++removed++"
    },
    "ifttt" : {
      "iftttChannelKey" : "++removed++",
      "iftttTestToken" : "++removed++"
    },
    "mail": {
      "host" : "siam-net.de",
      "port" : 465,
      "user" : "myopenhab@siam-net.de",
      "pass" : "++removed++"
    },
    "mongodb": {
        "hosts": ["127.0.0.1"],
        "db": "openhab-cloud",
      "user" : "openhab-cloud",
      "pass" : "++removed++"

    },
    "redis": {
        "host": "127.0.0.1",
        "port": "6379"

    },
    "mailer": {
        "host" : "siam-net.de",
        "port": 465,
        "secureConnection": true,
        "user": "myopenhab@siam-net.de",
        "password": "++removed++",
        "from": "openHAB Cloud <myopenhab@siam-net.de>"
    },
    "legal": {
        "terms" : "",
        "policy": ""
    },
    "registration_enabled": true
}

and here the Startup information from Openhab:

2020-08-05 12:00:56:5656 info: openHAB-cloud: Backend service is starting up...
2020-08-05 12:00:56:5656 info: openHAB-cloud: Backend logging initialized...
2020-08-05 12:00:57:5757 info: openHAB-cloud: Initializing XMPP connection to GCM
2020-08-05 12:00:57:5757 info: openHAB-cloud: Connecting to Redis at 127.0.0.1:6379
2020-08-05 12:00:58:5858 info: openHAB-cloud: Mailer will emulate sending in development environment
2020-08-05 12:00:58:5858 info: opneHAB-cloud: Trying to connect to mongodb at: mongodb://127.0.0.1/openhab-cloud?poolSize=100
2020-08-05 12:00:58:5858 info: openHAB-cloud: Scheduling a statistics job (every 5 min)
2020-08-05 12:00:58:5858 info: openHAB-cloud: IFTTT is configured, app handling IFTTT capabilities...
2020-08-05 12:00:58:5858 info: openHAB-cloud: express server listening on port 3000
2020-08-05 12:00:58:5858 info: openHAB-cloud: Redis is ready
2020-08-05 12:00:58:5858 info: openHAB-cloud: Successfully connected to mongodb
2020-08-05 12:00:59:5959 info: openHAB-cloud: GCM XMPP connection is online

At Startup, it seems the connection to mongo is ok but why i get this error when I will setup an account or if i try to login to openhab cloud?

MongoError: command find requires authentication

Can somebody point me in the right direction ?

Andy

Hi,
so now I have removed the authentication from the mongodb and now it works! Now is the question why ? I don’t like it to deactivate authentications of databases.

When a password is set can you connect to the mongo db by using this command at the shell:

mongo --host localhost --port "mongoport"  -u "mongouser" -p

replace “mongoport” with the port that is in use in your installation.
replace “mongusert” with the mongouser that you use in your installation.
You will be prompted to enter the passwort.
Does it connect ?
Use:

show databases

to list the databases that are available.
Run:

use openhab-cloud

to make openhab-cloud the active db.
Run:

show users

to show the available users for this db.