Setup your own openhab-cloud (myopenhab) server/instance

I was running a own openhabcloud since ages on a Strato Ubuntu 16.04 64bit system. Now I try to reinstall the cloud on a fresh Strato server with Ubuntu 18.04 64bit system.

Unfortunately without luck.

Here is what I did:

sudo apt-get update
sudo apt-get upgrade

sudo adduser openhabclouduser
usermod -aG sudo openhabclouduser
su - openhabclouduser

sudo apt-get install software-properties-common
sudo apt-get install curl
sudo apt install nginx
sudo apt install ufw

sudo add-apt-repository ppa:certbot/certbot
sudo apt-get install python-certbot-nginx
sudo certbot --nginx

sudo rm /etc/nginx/sites-enabled/default
sudo vim /etc/nginx/sites-enabled/hostname.de

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name hostname.de ;

    root /var/www/hostname.de;
    index index.html index.htm;
    location ~ /.well-known {
    	allow all;
    }
}

sudo mkdir /var/www/hostname.de
sudo vim /var/www/hostname.de/index.html

<h1>Test</h1>

sudo nginx -t
sudo systemctl reload nginx

sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'

sudo ufw enable

sudo certbot --nginx -d hostname.de -d www.hostname.de
sudo apt-get install letsencrypt
sudo letsencrypt certonly -a webroot --webroot-path=/var/www/hostname.de -d hostname.de

sudo apt-get install build-essential redis-server mongodb python git
sudo apt install npm

cd /home/openhabclouduser

wget https://nodejs.org/download/release/v7.10.1/node-v7.10.1-linux-x64.tar.gz

sudo mkdir -p /opt/nodejs

sudo tar -xvzf node-v7.10.1-linux-x64.tar.gz -C /opt/nodejs/

cd /opt/nodejs

sudo mv node-v7.10.1-linux-x64 7.10.1

sudo ln -s 7.10.1 current

sudo ln -s /opt/nodejs/current/bin/node /usr/bin/node

# This is to verify the node version

node -v

# It should say 7.10.1 now

# After that just clone the repo

cd /var/www/hostname.de

sudo git clone https://github.com/openhab/openhab-cloud.git 

sudo chmod 777 openhab-cloud/

cd openhab-cloud/
sudo npm install

Here ist the error:

openhabclouduser@h1123736 : /var/www/openhab-cloud $ sudo npm install

npm ERR! Linux 4.15.0

npm ERR! argv “/opt/nodejs/7.10.1/bin/node” “/usr/bin/npm” “install”

npm ERR! node v7.10.1

npm ERR! npm v3.5.2

npm ERR! code MODULE_NOT_FOUND

npm ERR! Cannot find module ‘ansi’

npm ERR!

npm ERR! If you need help, you may report this error at:

npm ERR! https://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request:

npm ERR! /var/www/hostname.de/openhab-cloud/npm-debug.log

Any help is more then welcome

It looks like your npm version is too old. It is version v3.5.2 but a newer one is expected.
See e.g. Cannot find module 'ansi' · Issue #19912 · npm/npm · GitHub

Mine is

npm list -g| grep npm
└─┬ npm@4.2.0

while I have

dpkg -l |grep nodejs
ii  nodejs                                7.10.1-2nodesource1~xenial1
1 Like

Thanks for the hint.
Now I get another exception:

2020-09-24 17:45:05:055 error: uncaughtException: Cannot find module ‘bcrypt’
Error: Cannot find module ‘bcrypt’
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/var/www/hostname.de/openhab-cloud/models/userdevice.js:3:14)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/var/www/hostname.de/openhab-cloud/fcm-xmpp.js:8:20)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
2020-09-24 17:45:05:055 error: undefined

Maybe there is another clever idea for me.
Found this

npm install --save bcrypt-nodejs && npm uninstall --save bcrypt

but does not solve the problem

npm log:

18955 verbose stack Error: heapdump@0.3.7 install: node-gyp rebuild
18955 verbose stack Exit status 1
18955 verbose stack at EventEmitter. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
18955 verbose stack at emitTwo (events.js:106:13)
18955 verbose stack at EventEmitter.emit (events.js:194:7)
18955 verbose stack at ChildProcess. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
18955 verbose stack at emitTwo (events.js:106:13)
18955 verbose stack at ChildProcess.emit (events.js:194:7)
18955 verbose stack at maybeClose (internal/child_process.js:899:16)
18955 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
18956 verbose pkgid heapdump@0.3.7
18957 verbose cwd /var/www/2kiwis.de/openhab-cloud
18958 verbose Linux 4.15.0
18959 verbose argv “/opt/nodejs/7.10.1/bin/node” “/usr/bin/npm” “install”
18960 verbose node v7.10.1
18961 verbose npm v6.14.6
18962 error code ELIFECYCLE
18963 error errno 1
18964 error heapdump@0.3.7 install: node-gyp rebuild
18964 error Exit status 1
18965 error Failed at the heapdump@0.3.7 install script.
18965 error This is probably not a problem with npm. There is likely additional logging output above.
18966 verbose exit [ 1, true ]

Thanks for your help

Is that error message triggered again by running the installer after fixing the first problem ?
When I look into the node_modules directory located in openhab-cloud then besides others I see these directories:

bcrypt/       bcrypt-cache/ bcrypt-pbkdf/

With these versions ( command started from within the openhab-cloud directory )

npm list |fgrep bcrypt
├─┬ bcrypt@1.0.2
├─┬ bcrypt-cache@1.0.2
│ ├─┬ bcrypt@0.8.7
│ │   ├── bcrypt-pbkdf@1.0.2

( installed this some time agoooo so it could be that other versions are expected now )

1 Like

Hey,
I habe set up my own OpenHAB-cloud Server and it Works Fine. Nur somehow I still cant Expose any items. They still wont appear on my Page.

Hi OS_Benji,
I have the same problem. I just opened another discussion here:

https://community.openhab.org/t/items-not-exposed-even-on-a-personal-instance-of-openhab-cloud-is-it-like-myopenhab-org/109210

All the best, Marco

1 Like

Hi Felix,

Did you solve the issue with bcrypt ?

I installed the cloud a couple of years ago without major problems. But now the file system of my server crashed and I was forced into a fresh install.
What a mess!
It seems the cloud is no longer maintained.

If you have any hints to get beyond the unavailable bcrypt package, please let us know.

Thx
-bernie

PS: in an earlier version of this post I falsely addressed Wolfgang: sorry!

According to the server headers nginx/1.10.3 is running on myopenhab.org.
The header also states that Ubuntu is running on it.
So according to the nginx version my conclusion would be that Ubuntu 16.04.X is running on that server.
Standard support ends in April 2021.

The only changes I see on git belong to updates related to OH3 although there are several users reporting back the same issues like those you have.

1 Like

Hi and Merry post- X-mas to everyone,

as already reported in reply #201, due to SD-card crash I lost my private cloud instance. After days of digging through this forum and Github, I have finally (!) managed to get the cloud back online. The time I invested to reinstall openhab-cloud was almost unbearable and if I hadn’t managed to install the cloud a couple of years ago, I would have given up by now and switched to different automation software.
HOWEVER, I did not. So, in case someone else runs into the same problem depicted in this post (and its replies), here’s my guide to saving precious live time :wink: .

Preface: Ryan’s installation guide is still pretty comprehensive but needs a couple of adaptions, almost three years after the intial post. The steps below have been tested on following platform (and most likely will work on different setups, as well):

OH Version: 2.4
HW: RPi Zero + ENC28J60
OS : dietpi v6.33.3 & nginx 1.14.2

  1. Make yourself familiar with Ryan’s post (this one).

  2. Step #7: Make sure, that you really DO install build-essential and python. Some users (including me) have reported that the installation process npm install broke, because the precompiled package bcrypt@1.0.2 was unavailable! According to bcrypt@github, this is not a problem: if a precompiled version of a package is unavailable for a specific platform, npm install falls back to compile from source automagically.

  3. Step #7: do not pull the master trunk of openhab-cloud at GitHub - I wasn’t able to get that one running. Instead, pull tag 1.0.10:
    git clone --depth 1 --branch 1.0.10 https://github.com/openhab/openhab-cloud.git

  4. Step #7: Make sure that you install NodeJS, no other than v7.10.1, the install process will fail otherwise. If there is no setup-script for your architecture, don’t worry! You can follow the manual install instructions on GitHub - no problem.

  5. Step #7: When I first tried to run the cloud with node app.js, the console log reported “unmet dependencies”. After a while of googling I found this on GitHub. If the cloud does not start after the first npm install, try at least
    npm install bcryptjs@^2.4.3 qunitjs@^2.0.0
    npm install node-time
    which will post-install 3 more packages.

  6. Reply #28 suggests using Unitech’s Process Manager PM2 to have app.js run as a system service. As openhab-cloud is tied to NodeJS v7.10.1, cloning the github repository from the latest branch is again no option. I found that PM2 versions below 4.x.x actually work with NodeJS v7.10.1
    npm install pm2@3.5.0 -g (as root) and then
    pm2 startup
    Consult Readme.MD for details on PM2!

Hope this helps!
Good luck & Best regards,
-bernie

3 Likes

this does not include the OH3 related changes.

Very true and thank you for the note! I still run OH 2.4 !
I will update my post, accordingly!

Has anyone launched a cloud on OH3?
Everything worked fine for me on OH2.5, but on OH3 I can’t go further than the HOME page.
A similar problem and its solution are described here https://github.com/openhab/openhab-cloud/issues/313, but nothing works for me.
Adding <“proxyHost”: home.openhab.mydomain.co> to config.json does not solve the problem. Apparently you need to implement all the actions described in the penultimate post, but here my knowledge is not enough.

Hello,

i tried to install the cloud server with the steps described at the first post.

At the point i have to start “app.js” i get the following error:

sudo node app.js
{"errno":-2,"syscall":"open","code":"ENOENT","path":"certs/aps/AuthKey.p8"}
(node:43041) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
node_redis: Warning: Redis server does not require a password, but a password was supplied.

I am trying to install it on a “fresh” vserver (ubuntu 20.04).

I found a similar issue. This seems to be due to the APN config. I do not use it, so I have a dummy config for it (oh-cloud won’t seem to start without it), but the file referred to in the signingKey parameter still neds to exist even if empty.

I have this in my config:

    "apn" : {
       [... rest of apm config here, even if "dummy" ...]
      "signingKey": "aps.p8"
    },

And then just created an empty “aps.p8” file in the same directory as the config.js.

Thank you!
I created the path /certs/aps/AuthKey.p8 with an empty file.

Also i removed the password line from config.json for redis.

After these two changed i only get one error message:

(node:43041) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)

Not using ubuntu myself, so not sure I can help on this one. But first of all, it is it working? (as the message suggests a warning, not an error).

If not working, what’s the output with --trace-warnings, and what version of mongodb are you using?

No, unfortunately it doesn’t work:

curl http://localhost:3000
curl: (7) Failed to connect to localhost port 3000: Connection refused

After start of app.js i get:

sudo node app.js
{}

I’m also having the same issues. When I moved from S2300 to S2306 my cloud connector started to have some issues. I attempted to update and now I’m down with the same errors.

EDIT: I’ve opened service not starting - apn related? · Issue #342 · openhab/openhab-cloud · GitHub to track.

I just merged Disables APNS if no APN or APN signingKey config is present by digitaldan · Pull Request #343 · openhab/openhab-cloud · GitHub which will disable loading APNS certs if there is no apn or apn.signingKey in your config, the latest docker container is building now. Make sure to remove the apn section from your config if not using apple’s push service.

I have removed the apn section and the node just crashes. Doesn’t write any logs either.

# node app.js
(node:12469) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
#