IoTP boilerplate application not working after Diego migration - ibm-cloud

After migrating my Watson IoTP boilerplate application to Diego, it not longer starts. I see this in the log:
[APP/0] OUT Welcome to Node-RED
[APP/0] OUT ===================
[APP/0] OUT 18 Jan 15:43:16 - [info] Node-RED version: v0.15.3
[APP/0] OUT 18 Jan 15:43:16 - [info] Node.js version: v4.6.2
[APP/0] OUT 18 Jan 15:43:16 - [info] Linux 4.4.0-45-generic x64 LE
[APP/0] OUT 18 Jan 15:43:16 - [info] Loading palette nodes
[APP/0] OUT 18 Jan 15:43:18 - [warn] [ibm hdfs in] Deprecated call to RED.runtime.nodes.registerType - node-set name must be provided as first argument
[APP/0] OUT 18 Jan 15:43:18 - [warn] [ibm hdfs] Deprecated call to RED.runtime.nodes.registerType - node-set name must be provided as first argument
[APP/0] OUT 18 Jan 15:43:18 - [warn] [ibmpush] Deprecated call to RED.runtime.nodes.registerType - node-set name must be provided as first argument
[APP/0] OUT 18 Jan 15:43:20 - [info] Settings file : /home/vcap/app/bluemix-settings.js
[APP/0] OUT 18 Jan 15:43:20 - [info] Server now running at http://127.0.0.1:`**1880**`/red/
[APP/0] OUT 18 Jan 15:43:20 - [info] Starting flows
[APP/0] OUT 18 Jan 15:43:20 - [info] Started flows
[CELL/0] ERR Timed out after 1m0s: health check never passed.
[CELL/0] OUT Exit status 0
[CELL/0] OUT Destroying container
[API/8] OUT App instance exited with guid ca3f2bbd-ac6e-42ec-8a61-1ff704274c3e payload: {"instance"=>"", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"2 error(s) occurred:\n\n* 1 error(s) occurred:\n\n* Exited with status 4\n* 2 error(s) occurred:\n\n* cancelled\n* process did not exit", "crash_count"=>2, "crash_timestamp"=>1484754267594231230, "version"=>"0361fa77-694c-4e8f-991e-0c52dd0c4c87"}
How can I fix this ?

The problem is that the way apps find the port to bind to has changed with Diego. The VCAP_APP_PORT environment variable is no longer populated by default. To fix it, you need to create a git repo for your app (Overview tab -> Continuous Delivery -> Add GIT). Use jazzhub to edit the bluemix-settings.js file to change
uiPort: process.env.VCAP_APP_PORT
to
uiPort: process.env.PORT
Deploy those changes and the app should start.

I had a similar issue with a npm express app and fixed it without having to edit the bluemix-settings.js file.
Simple remove all references to process.env.VCAP_APP_HOST (no longer a reference in Diego) and change process.env.VCAP_APP_PORT to process.env.PORT.
for example,
var host = 'localhost';
var port = (process.env.PORT || 1337);
app.listen(port, host);
console.log('App started on port ' + port);
You can check to see if your app is running Diego by typing:
cf has-diego-enabled APPNAME
after installing the diego cli tool
cf install-plugin Diego-Enabler -r CF-Community
I also disabled health checks:
cf set-health-check APPNAME none

Related

Error when runing 'flutterfire configure': HTTP Error: 403, The caller does not have permission

On flutterfire configure command I am getting this error.
OS: Fedora 36
[debug] [2022-06-09T16:49:47.182Z] ----------------------------------------------------------------------
[debug] [2022-06-09T16:49:47.184Z] Command: /usr/local/bin/firebase /home/virendra/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/bin/firebase projects:create my-notes-vcarp --json
[debug] [2022-06-09T16:49:47.185Z] CLI Version: 11.0.1
[debug] [2022-06-09T16:49:47.185Z] Platform: linux
[debug] [2022-06-09T16:49:47.185Z] Node Version: v16.15.0
[debug] [2022-06-09T16:49:47.186Z] Time: Thu Jun 09 2022 22:19:47 GMT+0530 (India Standard Time)
[debug] [2022-06-09T16:49:47.186Z] ----------------------------------------------------------------------
..
..
https://firebase.googleapis.com/v1beta1/projects/my-notes-vcarp:addFirebase {"error":{"code":403,"message":"The caller does not have permission","status":"PERMISSION_DENIED"}}
[debug] [2022-06-09T16:50:00.272Z] HTTP Error: 403, The caller does not have permission
[debug] [2022-06-09T16:50:00.277Z] FirebaseError: HTTP Error: 403, The caller does not have permission
at module.exports (/home/virendra/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/responseToError.js:47:12)
at RetryOperation._fn (/home/virendra/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/apiv2.js:286:39)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
[error]
[error] Error: Failed to add Firebase to Google Cloud Platform project. See firebase-debug.log for more info.
Create a project first directly on Firebase and then select it from the CLI options. Most likely, Flutterfire does not have Firebase permissions.
Thanks to Tomas Radvansky for their help.
simply just run firbase login:ci to generate access key before you run flutterfire configure command.

nodered on Raspberry PI is not starting any longer

I am not quite sure what node is causing this behaviour and there are tooo many flows so I can not install from scratch and yes I do not have a backup of them.
I realized today in the morning that I can not access the http gui of my nodered instance any longer on my raspberrypi zero. Just edited some flows but nothing real serious.
I am trying to start my node red on my Rapsberry PI zere and no GUI and UI is starting up to access the node red instance. I don't know how to solve and troubleshoot this. What I am doing or trying to do is:
pi#nodered-pi:~/.node-red $ node-red-start
Start Node-RED
Once Node-RED has started, point a browser at http://192.168.1.42:1880
On Pi Node-RED works better with the Firefox or Chrome browser
Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use node-red-log to view the recent log output
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot
Use sudo systemctl disable nodered.service to disable autostart on boot
To find more nodes and example flows - go to http://flows.nodered.org
Starting as a systemd service.
Started Node-RED graphical event wiring tool.
19 Aug 15:13:55 - [info]
Welcome to Node-RED
===================
19 Aug 15:13:55 - [info] Node-RED version: v0.18.7
19 Aug 15:13:55 - [info] Node.js version: v8.11.1
19 Aug 15:13:55 - [info] Linux 4.14.52+ arm LE
19 Aug 15:14:06 - [info] Loading palette nodes
19 Aug 15:14:37 - [info] Dashboard version 2.9.6 started at /ui
19 Aug 15:14:49 - [warn] ------------------------------------------------------
19 Aug 15:14:49 - [warn] [node-red-contrib-delta-timed/delta-time] 'delta' already registered by module node-red-contrib-change-detect
19 Aug 15:14:49 - [warn] ------------------------------------------------------
19 Aug 15:14:49 - [info] Settings file : /home/pi/.node-red/settings.js
19 Aug 15:14:49 - [info] User directory : /home/pi/.node-red
19 Aug 15:14:49 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
19 Aug 15:14:49 - [info] Flows file : /home/pi/.node-red/flows_nodered-pi.json
19 Aug 15:14:50 - [info] Server now running at http://127.0.0.1:1880/
19 Aug 15:14:50 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
19 Aug 15:14:50 - [warn] Error loading credentials: SyntaxError: Unexpected token T in JSON at position 0
19 Aug 15:14:50 - [warn] Error loading flows: Error: Failed to decrypt credentials
19 Aug 15:14:51 - [info] Starting flows
19 Aug 15:15:01 - [warn] [telegram receiver:Telegram Receiver] bot not initialized
19 Aug 15:15:01 - [warn] [telegram sender:Temperatur Wetterstation] bot not initialized.
19 Aug 15:15:01 - [error] [function:Versorge mit Information] SyntaxError: Invalid or unexpected token
19 Aug 15:15:01 - [info] Started flows
19 Aug 15:15:02 - [info] [sonoff-server:166ef3ba.0029bc] SONOFF Server Started On Port 1080
19 Aug 15:15:02 - [red] Uncaught Exception:
19 Aug 15:15:02 - Error: listen EACCES 0.0.0.0:443
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Unit entered failed state.
nodered.service: Failed with result 'exit-code'.
nodered.service: Service hold-off time over, scheduling restart.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
19 Aug 15:15:20 - [info]
Welcome to Node-RED
===================
19 Aug 15:15:20 - [info] Node-RED version: v0.18.7
19 Aug 15:15:02 - Error: listen EACCES 0.0.0.0:443
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
This error implies that something else is already running on port 443. This could be an existing copy of Node-RED or something else. You can search what applications are listening on what ports with the following command
lsof -i :443
This will list what is listening on port 443

Node-red email node keeps crashing

I have a simple email node and debug-node set-up within a web application using node red.
The email node has refresh time set to 5 seconds. and protocol IMAP.
I have a gmail account logged in.
Node-red crashes with the following error:
(Happens rather quickly when I receive an email with an attachment of > 10mb).
The TypeError is on different properties like 'name', 'type' '11456' etc...
10 Jul 17:00:28 - [info] Starting flows
10 Jul 17:00:28 - [info] Started flows
10 Jul 17:00:37 - [red] Uncaught Exception:
10 Jul 17:00:37 - TypeError: Cannot set property 'name' of undefined
at Connection.<anonymous> (/usr/lib/node_modules/node-red/node_modules/imap/lib/Connection.js:431:22)
at Connection._resTagged (/usr/lib/node_modules/node-red/node_modules/imap/lib/Connection.js:1535:22)
at Parser.<anonymous> (/usr/lib/node_modules/node-red/node_modules/imap/lib/Connection.js:194:10)
at emitOne (events.js:116:13)
at Parser.emit (events.js:211:7)
at Parser._resTagged (/usr/lib/node_modules/node-red/node_modules/imap/lib/Parser.js:175:10)
at Parser._parse (/usr/lib/node_modules/node-red/node_modules/imap/lib/Parser.js:139:16)
at Parser._tryread (/usr/lib/node_modules/node-red/node_modules/imap/lib/Parser.js:82:15)
at TLSSocket.Parser._cbReadable (/usr/lib/node_modules/node-red/node_modules/imap/lib/Parser.js:53:12)
at emitNone (events.js:106:13)
Versions:
10 Jul 17:00:27 - [info] Node-RED version: v0.18.7
10 Jul 17:00:27 - [info] Node.js version: v8.11.3
10 Jul 17:00:27 - [info] Linux 4.15.0-24-generic x64 LE
Package.json :
"dependencies": {
"imap": "^0.8.19",
"mailparser": "^0.6.2",
"nodemailer": "^1.11.0",

Why is my node-red app returning 404 route error in ibm-cloud?

My node-red app in bluemix was working, but now it doesn't let me access the route. It worked before and I have not modified it.
I am getting this error:
404 Not Found: Requested route ('route.mybluemix.net') does not exist.
The recent logs are:
2018-04-16T09:37:46.60-0300 [CELL/0] OUT Creating container
2018-04-16T09:37:47.42-0300 [CELL/0] OUT Successfully created container
2018-04-16T09:37:54.32-0300 [CELL/0] OUT Starting health monitoring of container
2018-04-16T09:37:55.41-0300 [APP/PROC/WEB/0] OUT > node-red-bluemix#0.8.0 start /home/vcap/app
2018-04-16T09:37:55.41-0300 [APP/PROC/WEB/0] OUT > node --max-old-space-size=180 index.js --settings ./bluemix-settings.js -v
2018-04-16T09:37:55.62-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:37:55 - Starting Node-RED on IBM Cloud bootstrap
2018-04-16T09:37:55.62-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:37:55 - Loading bluemix-settings.js
2018-04-16T09:37:55.72-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:37:55 - Using Cloudant service: /^NodeRed.cloudantNoSQLDB/ : NodeRed
2018-04-16T09:37:56.08-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:37:56 - Loading application settings
2018-04-16T09:37:56.22-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:37:56 - Using runtime settings for adminAuth
2018-04-16T09:37:56.77-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:37:56 - [info]
2018-04-16T09:37:56.77-0300 [APP/PROC/WEB/0] OUT Welcome to Node-RED
2018-04-16T09:37:56.77-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:37:56 - [info] Linux 4.4.0-109-generic x64 LE
2018-04-16T09:37:56.77-0300 [APP/PROC/WEB/0] OUT ===================
2018-04-16T09:37:56.77-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:37:56 - [info] Node-RED version: v0.18.2
2018-04-16T09:37:56.77-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:37:56 - [info] Node.js version: v6.12.3
2018-04-16T09:37:57.25-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:37:57 - [info] Loading palette nodes
2018-04-16T09:37:59.99-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:37:59 - [warn] Missing node modules:
2018-04-16T09:37:59.99-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:37:59 - [warn] - node-red-contrib-telegrambot (2.7.3): telegram bot, telegram receiver, telegram command, telegram callback_query, telegram sender, telegram reply
2018-04-16T09:37:59.99-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:37:59 - [warn] - node-red-contrib-play-audio (2.2.4): play audio
2018-04-16T09:37:59.99-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:37:59 - [warn] - node-red-contrib-browser-utils (0.0.5): fileinject, microphone, camera
2018-04-16T09:38:00.00-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:38:00 - [info] Installing module: node-red-contrib-play-audio, version: 2.2.4
2018-04-16T09:37:59.99-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:37:59 - [info] Installing module: node-red-contrib-telegrambot, version: 2.7.3
2018-04-16T09:38:00.21-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:38:00 - [info] Installing module: node-red-contrib-browser-utils, version: 0.0.5
2018-04-16T09:38:00.30-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:38:00 - [info] Settings file : /home/vcap/app/bluemix-settings.js
2018-04-16T09:38:00.30-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:38:00 - [info] HTTP Static : /home/vcap/app/public
2018-04-16T09:38:00.44-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:38:00 - [info] Server now running at http://127.0.0.1:8080/red/
2018-04-16T09:38:00.60-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:38:00 - [info] Waiting for missing types to be registered:
2018-04-16T09:38:00.60-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:38:00 - [info] - telegram bot
2018-04-16T09:38:00.60-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:38:00 - [info] - telegram receiver
2018-04-16T09:38:00.60-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:38:00 - [info] - telegram sender
2018-04-16T09:38:00.60-0300 [APP/PROC/WEB/0] OUT 16 Apr 12:38:00 - [info] - microphone
2018-04-16T09:38:00.92-0300 [CELL/0] OUT Container became healthy
2018-04-16T09:38:03.47-0300 [APP/PROC/WEB/0] ERR Killed
2018-04-16T09:38:03.49-0300 [APP/PROC/WEB/0] ERR npm ERR! Linux 4.4.0-109-generic
2018-04-16T09:38:03.49-0300 [APP/PROC/WEB/0] ERR npm ERR! argv "/home/vcap/app/vendor/node/bin/node" "/home/vcap/app/vendor/node/bin/npm" "start"
2018-04-16T09:38:03.49-0300 [APP/PROC/WEB/0] ERR npm ERR! node v6.12.3
2018-04-16T09:38:03.49-0300 [APP/PROC/WEB/0] ERR npm ERR! npm v3.10.10
2018-04-16T09:38:03.49-0300 [APP/PROC/WEB/0] ERR npm ERR! code ELIFECYCLE
2018-04-16T09:38:03.49-0300 [APP/PROC/WEB/0] ERR npm ERR! node-red-bluemix#0.8.0 start: `node --max-old-space-size=180 index.js --settings ./bluemix-settings.js -v`
2018-04-16T09:38:03.49-0300 [APP/PROC/WEB/0] ERR npm ERR! Exit status 137
2018-04-16T09:38:03.49-0300 [APP/PROC/WEB/0] ERR npm ERR!
2018-04-16T09:38:03.49-0300 [APP/PROC/WEB/0] ERR npm ERR! Failed at the node-red-bluemix#0.8.0 start script 'node --max-old-space-size=180 index.js --settings ./bluemix-settings.js -v'.
2018-04-16T09:38:03.49-0300 [APP/PROC/WEB/0] ERR npm ERR! Make sure you have the latest version of node.js and npm installed.
2018-04-16T09:38:03.49-0300 [APP/PROC/WEB/0] ERR npm ERR! If you do, this is most likely a problem with the node-red-bluemix package,
2018-04-16T09:38:03.49-0300 [APP/PROC/WEB/0] ERR npm ERR! not with npm itself.
2018-04-16T09:38:03.49-0300 [APP/PROC/WEB/0] ERR npm ERR! Tell the author that this fails on your system:
2018-04-16T09:38:03.50-0300 [APP/PROC/WEB/0] ERR npm ERR! node --max-old-space-size=180 index.js --settings ./bluemix-settings.js -v
2018-04-16T09:38:03.50-0300 [APP/PROC/WEB/0] ERR npm ERR! You can get information on how to open an issue for this project with:
2018-04-16T09:38:03.50-0300 [APP/PROC/WEB/0] ERR npm ERR! npm bugs node-red-bluemix
2018-04-16T09:38:03.50-0300 [APP/PROC/WEB/0] ERR npm ERR! Or if that isn't available, you can get their info via:
2018-04-16T09:38:03.50-0300 [APP/PROC/WEB/0] ERR npm ERR! npm owner ls node-red-bluemix
2018-04-16T09:38:03.50-0300 [APP/PROC/WEB/0] ERR npm ERR! There is likely additional logging output above.
2018-04-16T09:38:03.53-0300 [APP/PROC/WEB/0] ERR npm ERR! Please include the following file with any support request:
2018-04-16T09:38:03.53-0300 [APP/PROC/WEB/0] ERR npm ERR! /home/vcap/app/npm-debug.log
2018-04-16T09:38:03.61-0300 [APP/PROC/WEB/0] OUT Exit status 1 (out of memory)
Before I didn't have all this errors, I have not modified my nodes.
When Node-RED restarts in the IBM Cloud it has to check if it still has all the extra nodes added via the palette manager. That is because those nodes don't get added to the stored application image so are lost on a restage.
If it finds anything is missing, Node-RED will then dynamically reinstall them. You can see in the log it kicking off three reinstalls. This is where the problem is.
By installing these nodes in parallel, the application is most likely running out of memory and getting killed. For a lite account, you only have 256Mb to play with - which is not much.
You have two possible workarounds:
enable the continuous delivery feature (last I looked, bottom right on the applications IBM Cloud dashboard page). That will give you a git repository you can edit the source in. Edit the package.json file to include these additional node modules under the dependencies section. That will ensure the nodes are installed as part of the application image and won't need reinstalling on restart.
upgrade to a standard account where you'll be able to up your application to 512Mb of memory for free.
Since the Lite account was introduced with its 256Mb memory limit, we see this scenario more often. We will have to look at the reinstall code to see about making the installs happen sequentially rather than in parallel. It'll take longer, but should minimise the memory usage.

How to start Scala Play application on Bluemix?

I have basic Scala application on Play framework and I try to deploy it to IBM Bluemix. During deployment it shows next:
an instance of the app crashed: failed to accept connections within health check timeout
exit status: -1, CRASHED
My manifest.yml
applications:
- path: ./target/universal/scala-bluemix-1.0-SNAPSHOT.zip
memory: 512M
instances: 1
domain: eu-gb.mybluemix.net
name: TestApp1WithTotalyUniqueName
host: testapp1withtotalyuniquename
disk_quota: 1024M
I have already checked this link: http://blog.ibmjstart.net/2015/10/27/a-play-scala-server-running-on-ibm-bluemix/
Any ideas how to fix it?
Output from console:
2015-11-03T18:30:50.70+0200 [STG/0] OUT -----> Liberty buildpack is done creating the droplet
2015-11-03T18:30:51.31+0200 [STG/0] ERR
2015-11-03T18:31:00.89+0200 [STG/115] OUT -----> Uploading droplet (91M)
2015-11-03T18:31:11.91+0200 [DEA/115] OUT Starting app instance (index 0) with guid b634d704-85f2-4e42-b559-985de67c90ae
2015-11-03T18:31:30.09+0200 [App/0] OUT [info] - play.api.Play - Application started (Prod)
2015-11-03T18:31:30.23+0200 [App/0] OUT [info] - play.core.server.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
2015-11-03T18:32:22.04+0200 [DEA/115] ERR Instance (index 0) failed to start accepting connections
2015-11-03T18:32:22.05+0200 [API/7] OUT App instance exited with guid b634d704-85f2-4e42-b559-985de67c90ae payload: {"cc_partition"=>"default", "droplet"=>"b634d704-85f2-4e42-b559-985de67c90ae", "version"=>"1b3e8d86-501a-4679-9104-9a9dea063ccd", "instance"=>"19d1570c9865486985c6f159a90233dd", "index"=>0, "reason"=>"CRASHED", "exit_status"=>-1, "exit_description"=>"failed to accept connections within health check timeout", "crash_timestamp"=>1446568342}
2015-11-03T18:32:22.07+0200 [App/0] ERR
2015-11-03T18:32:52.39+0200 [DEA/112] OUT Starting app instance (index 0) with guid b634d704-85f2-4e42-b559-985de67c90ae
2015-11-03T18:33:04.31+0200 [App/0] OUT [info] - play.api.Play - Application started (Prod)
2015-11-03T18:33:04.43+0200 [App/0] OUT [info] - play.core.server.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
And this line was missing in manifest.yml:
buildpack: java_buildpack