Lost connection to server, reconnecting in

Try re-installing that node. Go to your .node-red directory and run

npm remove node-red-contrib-telegrambot`
npm install telegrambot

If it fails then post the output here.

Hold on though, that node is not even in use, so remove it, go to your .node-red directory and run
npm remove node-red-contrib-telegrambot

Hi i've seen this issue with all node show at once before here

The solution was to update node-red.

pi@raspberrypi:~ $ npm remove node-red-contrib-telegrambot
npm WARN saveError ENOENT: no such file or directory, open '/home/pi/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/pi/package.json'
npm WARN pi No description
npm WARN pi No repository field.
npm WARN pi No README data
npm WARN pi No license field.

audited 364 packages in 8.349s
found 35 vulnerabilities (22 moderate, 13 high)
  run `npm audit fix` to fix them, or `npm audit` for details
pi@raspberrypi:~ $

As I said,

cd .node-red

npm uninstall node-red-contrib-telegrambot

npm uninstall node-red-contrib-modbus

...and as @Steve-Mcl has said - update node-RED using the installation script -

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

@Colin isn't it npm uninstall instead of npm remove or do both work?

Still no joy, I followed your instructions Paul

Sorry for the delay - I was 'instructed':grin: that I had to go for our once a day walk :walking_man:

pi@raspberrypi:~/.node-red $ node-red-start

Start Node-RED

Once Node-RED has started, point a browser at http://192.168.2.40: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.
12 Apr 16:13:18 - [info] Stopped flows
Stopped Node-RED graphical event wiring tool.
Starting Node-RED graphical event wiring tool...
Started Node-RED graphical event wiring tool.
12 Apr 16:13:25 - [info]
Welcome to Node-RED
===================
12 Apr 16:13:25 - [info] Node-RED version: v1.0.5
12 Apr 16:13:25 - [info] Node.js  version: v10.16.0
12 Apr 16:13:25 - [info] Linux 4.9.35-v7+ arm LE
12 Apr 16:13:27 - [info] Loading palette nodes
12 Apr 16:13:32 - [info] Dashboard up and running
12 Apr 16:13:37 - [info] Worldmap version 2.0.18
12 Apr 16:13:37 - [info] Dashboard version 2.15.5 started at /ui
12 Apr 16:13:40 - [warn] ------------------------------------------------------
12 Apr 16:13:40 - [warn] [node-red-contrib-telegrambot/telegrambot] Error: Cannot find module 'array.prototype.findindex'
12 Apr 16:13:40 - [warn] [node-red-contrib-ibm-watson-iot/wiotp] Error: Cannot find module 'format'
12 Apr 16:13:40 - [warn] [node-red-contrib-modbus/Modbus-Client] Error: Cannot find module 'source-map-support' (line:1)
12 Apr 16:13:40 - [warn] [node-red-contrib-modbus/Modbus-Response] Error: Cannot find module 'source-map-support' (line:1)
12 Apr 16:13:40 - [warn] [node-red-contrib-modbus/Modbus-Read] Error: Cannot find module 'source-map-support' (line:1)
12 Apr 16:13:40 - [warn] [node-red-contrib-modbus/Modbus-Getter] Error: Cannot find module 'source-map-support' (line:1)
12 Apr 16:13:40 - [warn] [node-red-contrib-modbus/Modbus-Flex-Getter] Error: Cannot find module 'source-map-support' (line:1)
12 Apr 16:13:40 - [warn] [node-red-contrib-modbus/Modbus-Write] Error: Cannot find module 'source-map-support' (line:1)
12 Apr 16:13:40 - [warn] [node-red-contrib-modbus/Modbus-Flex-Write] Error: Cannot find module 'source-map-support' (line:1)
12 Apr 16:13:40 - [warn] [node-red-contrib-modbus/Modbus-Server] Error: Cannot find module 'source-map-support' (line:1)
12 Apr 16:13:40 - [warn] [node-red-contrib-modbus/Modbus-Flex-Server] Error: Cannot find module 'source-map-support' (line:1)
12 Apr 16:13:40 - [warn] [node-red-contrib-modbus/Modbus-Queue-Info] Error: Cannot find module 'source-map-support' (line:1)
12 Apr 16:13:40 - [warn] [node-red-contrib-modbus/Modbus-Flex-Connector] Error: Cannot find module 'source-map-support' (line:1)
12 Apr 16:13:40 - [warn] [node-red-contrib-modbus/Modbus-IO-Config] Error: Cannot find module 'source-map-support' (line:1)
12 Apr 16:13:40 - [warn] [node-red-contrib-modbus/Modbus-Response-Filter] Error: Cannot find module 'source-map-support' (line:1)
12 Apr 16:13:40 - [warn] ------------------------------------------------------
12 Apr 16:13:40 - [info] Settings file  : /home/pi/.node-red/settings.js
12 Apr 16:13:40 - [info] Context store  : 'default' [module=memory]
12 Apr 16:13:40 - [info] User directory : /home/pi/.node-red
12 Apr 16:13:40 - [warn] Projects disabled : editorTheme.projects.enabled=false
12 Apr 16:13:40 - [info] Flows file     : /home/pi/.node-red/flows_raspberrypi.json
12 Apr 16:13:40 - [info] Server now running at http://127.0.0.1:1880/
12 Apr 16:13:40 - [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.
---------------------------------------------------------------------
12 Apr 16:13:41 - [info] Starting flows
12 Apr 16:13:42 - [info] [worldmap:map] started at /worldmap
12 Apr 16:13:43 - [info] Started flows
12 Apr 16:13:44 - [info] [mqtt-broker:bf503048.2a203] Connected to broker: mqtt://192.168.2.40:1883
12 Apr 16:13:44 - [info] [mqtt-broker:dcf64bcc.458bb8] Connected to broker: mqtt://192.168.2.60:1883
12 Apr 16:13:44 - [info] [mqtt-broker:CloudMQTT] Connected to broker: mqtts://m23.cloudmqtt.com:26499
12 Apr 16:13:46 - [info] [e-mail:myemail@hotmail.com] Message sent: 250 2.0.0 Ok: queued as CC85DFF803
12 Apr 16:13:46 - [info] [e-mail:myemail@hotmail.com] Message sent: 250 2.0.0 Ok: queued as 15ACC1BF204

Show us the log from the npm uninstall of telegrambot and modbus.
It doesn't matter if it is gone, just run it again.

pi@raspberrypi:~ $ cd .node-red
pi@raspberrypi:~/.node-red $ npm uninstall node-red-contrib-telegrambot
audited 650 packages in 22.229s
found 7 vulnerabilities (4 low, 3 high)
  run `npm audit fix` to fix them, or `npm audit` for details
pi@raspberrypi:~/.node-red $ npm uninstall node-red-contrib-modbus
audited 650 packages in 22.163s
found 7 vulnerabilities (4 low, 3 high)
  run `npm audit fix` to fix them, or `npm audit` for details
pi@raspberrypi:~/.node-red $

Try

sudo npm uninstall -g node-red-contrib-telegrambot
sudo npm uninstall -g node-red-contrib-modbus
pi@raspberrypi:~ $ cd .node-red
pi@raspberrypi:~/.node-red $ sudo npm uninstall -g node-red-contrib-telegrambot

up to date in 0.472s


   โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
   โ”‚                                                                โ”‚
   โ”‚       New minor version of npm available! 6.9.0 โ†’ 6.14.1       โ”‚
   โ”‚   Changelog: https://github.com/npm/cli/releases/tag/v6.14.1   โ”‚
   โ”‚               Run npm install -g npm to update!                โ”‚
   โ”‚                                                                โ”‚
   โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

pi@raspberrypi:~/.node-red $ sudo npm uninstall -g node-red-contrib-modbus
up to date in 0.43s


   โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
   โ”‚                                                                โ”‚
   โ”‚       New minor version of npm available! 6.9.0 โ†’ 6.14.4       โ”‚
   โ”‚   Changelog: https://github.com/npm/cli/releases/tag/v6.14.4   โ”‚
   โ”‚               Run npm install -g npm to update!                โ”‚
   โ”‚                                                                โ”‚
   โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

pi@raspberrypi:~/.node-red $

Is there a possibility I could be two lots of node-red ? - just a thought...

Very odd. You can see from the log that you are executing the one in .node-red. if you look in the folder `.node-red/node_modules and see whether node-red-contrib-modbus exists. If so delete it.
Have you run the node red update script as suggested earlier in case you somehow have an incompatible version of npm installed?

It had and I deleted it , and after a restart. I'll run the update script now



pi@raspberrypi:~/.node-red $ node-red-start

Start Node-RED

Once Node-RED has started, point a browser at http://192.168.2.40: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.
12 Apr 17:54:54 - [info]
Welcome to Node-RED
===================
12 Apr 17:54:54 - [info] Node-RED version: v1.0.5
12 Apr 17:54:54 - [info] Node.js  version: v10.16.0
12 Apr 17:54:54 - [info] Linux 4.9.35-v7+ arm LE
12 Apr 17:54:56 - [info] Loading palette nodes
12 Apr 17:55:02 - [info] Dashboard up and running
12 Apr 17:55:06 - [info] Worldmap version 2.0.18
12 Apr 17:55:07 - [info] Dashboard version 2.15.5 started at /ui
12 Apr 17:55:09 - [warn] ------------------------------------------------------
12 Apr 17:55:09 - [warn] [node-red-contrib-telegrambot/telegrambot] Error: Cannot find module 'array.prototype.findindex'
12 Apr 17:55:09 - [warn] [node-red-contrib-ibm-watson-iot/wiotp] Error: Cannot find module 'format'
12 Apr 17:55:09 - [warn] ------------------------------------------------------
12 Apr 17:55:09 - [warn] Missing node modules:
12 Apr 17:55:09 - [warn]  - node-red-contrib-modbus (4.1.1): modbus-client, modbus-response, modbus-read, modbus-getter, modbus-flex-                                   getter, modbus-write, modbus-flex-write, modbus-server, modbus-flex-server, modbus-queue-info, modbus-flex-connector, modbus-io-confi                                   g, modbus-response-filter
12 Apr 17:55:09 - [info] Removing modules from config
12 Apr 17:55:09 - [info] Settings file  : /home/pi/.node-red/settings.js
12 Apr 17:55:09 - [info] Context store  : 'default' [module=memory]
12 Apr 17:55:09 - [info] User directory : /home/pi/.node-red
12 Apr 17:55:09 - [warn] Projects disabled : editorTheme.projects.enabled=false
12 Apr 17:55:09 - [info] Flows file     : /home/pi/.node-red/flows_raspberrypi.json
12 Apr 17:55:09 - [info] Server now running at http://127.0.0.1:1880/
12 Apr 17:55:09 - [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.
---------------------------------------------------------------------
12 Apr 17:55:10 - [info] Starting flows
12 Apr 17:55:11 - [info] [worldmap:map] started at /worldmap
12 Apr 17:55:12 - [info] Started flows
12 Apr 17:55:13 - [info] [mqtt-broker:bf503048.2a203] Connected to broker: mqtt://192.168.2.40:1883
12 Apr 17:55:13 - [info] [mqtt-broker:dcf64bcc.458bb8] Connected to broker: mqtt://192.168.2.60:1883
12 Apr 17:55:13 - [info] [mqtt-broker:CloudMQTT] Connected to broker: mqtts://m23.cloudmqtt.com:26499
12 Apr 17:55:15 - [info] [e-mail:myemail@hotmail.com] Message sent: 250 2.0.0 Ok: queued as C0C2360004
12 Apr 17:55:15 - [info] [e-mail:myemail@hotmail.com] Message sent: 250 2.0.0 Ok: queued as 36375C0008


Thanks Colin, That got rid of the Telegram,Modbus and Watson-iot errors deleting them from .node-red/node-modules folder. Still have the lost connection error

Can we eliminate any problems with your flows, but BEFORE DOING SO... @Colin OR @Steve-Mcl do you agree with this suggestion?

What this will do is automatically create a new, blank flows file.

You have sorted the contrib-nodes problem, reinstalled node-RED, so this will eliminate any problems that you may have with your flows.

So...

node-red-stop

cd .node-red

mv flows_raspberrypi.json backup_of_flows_file
(That will rename your flows file so node-RED will not be able to access it)

rm .flows_raspberrypi.json.backup
(Delete the flows file backup just to make sure node-RED doesn't access it)

node-red-start

If it connects ok, then it points to a problem in your flows, if not, then I'm out of ideas :thinking:

If npm remove didn't remove the nodes but didn't complain then I think there must be something seriously wrong with the install, that is why I think maybe uninstalling npm and nodejs and re-installing might be a good way to go. If you decide to go that route then

sudo apt remove npm
sudo apt remove nodejs

and run the install script. No harm in trying the blank flow file test first though.

I think I fixed it :nerd_face: just by reloading the node_modules folder from a backup I have - I'm think I did this before to no avail. I did delete the problematic nodes from before Telegram,Modbus and Watson-iot before I copied them over.

I did try Paul, your suggestion of renaming and deleting the flows but I still had the same problem. Colin, I didn't try deleting npm and nodejs I tried copying the node first.

I think a good sleep helped refocus my mind rather than just randomly trying things being tried and fed up.

The moral of the story is BACKUP then backup again before you change anything !

1 Like

Replacing node_modules will probably only be a temporary fix. If you now have a node_modules which is out of step with package.json then at some point npm will 'fix' that for you and you may be back at square 1.

The install script doesn't "go backwards" so if you have 13 already installed it will leave it. If you really need to go backwards then you need to manually uninstall node and npm and then also remove the sources file (usually /etc/apt/sources.list.d/nodesource.list) and then re-run the install script

The nuclear way to do this on a Pi is.

sudo rm -rf /usr/bin/node* /usr/bin/npm /usr/lib/node* /etc/apt/sources.list.d/nodesource.list
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)