Can't access gateway

I’ve been running Webthings on a R-Pi3 for the last 9 months or so and it was running relatively smoothly until about a week ago.

The first problem that arose was the Zigbee adapter couldn’t connect to its Things. Everything else appeared to be working OK (Z-Wave devices continued working, Rules, accessing the Gateway). This seemed to happen after an Zigbee adapter update, so I logged an issue here. It was closed immediately and it looks like another update was sent out overnight, but this didn’t fix the problem.

Within a day, I could no longer access the Gateway at all (either locally or externally) and the Z-Wave devices (or the Rules) no longer activated.

I don’t know that these two issues (Zigbee adapter and the Gateway) are necessarily related, only that they occurred within a day or two.

I should also note that since I set up the Webthings last year, I had to get a new router from my ISP. There has been an intermittent problem like the one I have now, in that every couple of weeks I wouldn’t be able to access the Gateway locally or externally, but all I had to do was restart the R-Pi and it would then be fine. I found reference via ISP forums that this is happening with other IOT gateways with this router. Obviously, restarting the R-Pi is not working for me now. I have also tried resetting the router, but that didn’t fix or change the problem.

The behaviour seems very similar to this and this topic, but there were no suggestions in there that have helped.

To summarise:

  • From what I can tell, the R-Pi appear to boot up OK
  • It obtains an IP address (via wireless) and I can see the R-Pi through the router portal (and it’s name is webthings)
  • I can ping the R-Pi
  • I can SSH to the R-Pi
  • I can ping the internet from the R-Pi

Any ideas?

Are there log files that might shed light? If so, please be specific – I’m a novice. I can see that there have been no new log files generated in the .webthings/log directory since the time I think the Gateway became inaccessible – not sure if that is relevant.

Thanks for any help.
Brad

Hi Brad,

Sorry you’re having problems. Can I first check that your gateway has updated to 1.0 and that you have transitioned from a mozilla-iot.org domain to a webthings.io domain? (See this blog post for more information.)

That should not prevent you accessing the gateway locally though, so may not be the problem. Can you access the gateway’s web interface by typing its local IP address into your browser (the IP you can see being assigned by your router)?

What do you see if you type ps aux | grep gateway on the command line on the Raspberry Pi?

The Zigbee issue was supposed by fixed in https://github.com/WebThingsIO/zigbee-adapter/commit/46124244ff0ae0c8b117d05185e2380a0e1a06b3 by @mrstegeman so perhaps he can comment on that.

Hi Ben

Thanks for your help.

I received email confirmation of transition to webthings.io domain on 22 Dec and I’m sure I checked that accessing the gateway through this domain worked.

I’m assuming that the gateway updated to 1.0 at that time, but I can’t remember specifically checking that it did. I can see that the R-Pi has folders for .mozilla-iot, .mozilla-iot.old and .webthings. Is this expected after the update? Is there any other way to confirm that the update has been installed properly?

I cannot access the gateway locally through a browser (Edge on PC or Android, Chrome on Android) either via local IP address or webthings.local (or gateway.local).

Typing ps aux | grep gateway on the command line on the Raspberry Pi delivers:

pi 17799 0.0 0.0 7348 488 pts/0 S+ 12:14 0:00 grep --color=auto gateway

Let me know what to do next!
Brad

Yes, I have those folders too.

It looks like the gateway is failing to start. Can you see any errors in ~/.webthings/log/run-app.log ?

OK, all the errors in the latest run-app.log relate to weather-adapter. That log file is dated 2021-01-30, and this grouping of errors occurs 3 times in the file – presuming that it’s tried to start itself again after a period? There have been no log files since then, even though I’ve restarted the R-Pi quite a few times since then.

2021-01-30 09:11:43.361 ERROR : weather-adapter: Failed to poll weather provider: { FetchError: request to https://api.openweathermap.org/data/2.5/weather?lat=-37.95&lon=144.93&units=metric&appid=2bc03e37c3bac538da91803f1a4c2a3b failed, reason: Client network socket disconnected before secure TLS connection was established
2021-01-30 09:12:11.478 ERROR : weather-adapter: at ClientRequest. (/home/pi/.webthings/addons/weather-adapter/node_modules/node-fetch/lib/index.js:1461:11)
2021-01-30 09:12:36.572 ERROR : weather-adapter: at ClientRequest.emit (events.js:198:13)
2021-01-30 09:12:52.733 ERROR : weather-adapter: at TLSSocket.socketErrorListener (_htt0_client.js:401:9)
2021-01-30 09:13:17.602 ERROR : weather-adapter: at TLSSocket.emit (events.js:198:13)
2021-01-30 09:13:45.800 ERROR : weather-adapter: at emitErrorNT (internal/streams/destroy.js:91:8)
2021-01-30 09:14:05.067 ERROR : weather-adapter: at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
2021-01-30 09:14:19.693 ERROR : weather-adapter: at process._tickCallback (internal/process/next_tick.js:63:19)
2021-01-30 09:14:39.728 ERROR : weather-adapter: message:
2021-01-30 09:14:52.800 ERROR : weather-adapter: ‘request to https://api.openweathermap.org/data/2.5/weather?lat=-37.95&lon=144.93&units=metric&appid=2bc03e37c3bac538da91803f1a4c2a3b failed, reason: Client network socket disconnected before secure TLS connection was established’,
2021-01-30 09:15:10.396 ERROR : weather-adapter: type: ‘system’,
2021-01-30 09:15:23.332 ERROR : weather-adapter: errno: ‘ECONNRESET’,
2021-01-30 09:15:51.924 ERROR : weather-adapter: code: ‘ECONNRESET’ }

I would be very surprised if the weather add-on is preventing the gateway from running, as add-ons run in a separate process.

Something is definitely preventing the gateway application from starting, but I’m afraid I can’t tell what from this information.

What happens if you try to run ~/webthings/gateway/run-app.sh manually on the command line?

One option to “test”, would be to run a clean/new Gateway image using it’s DOCKER container to isolate it from the core OS. You can easily start and make changes, and then rinse-and-repeate until the issue is found.

After starting the container for the first time and running through the installation process you can shut down the image and copy the base configuration folders to a “golden” backup. Then shutdown, restore, boot, and tweak as needed. In your case, testing basic access w/o addons would be your first test and adding the weather addon next.

On my rpi, I maintain seperate boot images and configuration folders for each WebThing release allowing me to easily boot into any of them.

At lease you would be able to determine if it’s a new WT installation with only the Weather addon installed.

Use hard-coded IPs; alternate DNS servers; verify network stays up; use eth switch rather than ports on the router; doing apt-get update/upgrade on the rpi;

The only other lines in the log files from the days before the gateway closed are INFO rather than ERROR:

  • Thousands of the following entry over minutes or even a few seconds. I wonder if this relates to a poorly constructed timer I’ve set up?

INFO : DeviceProxy: requestAction: restart for: timer-b60a4ac89c575c0abe7a5d52a4b10640

  • And, the only other entry I can see:

INFO : zigbee-adapter: Kicking WatchDog for 3600 seconds


When I run ~/webthings/gateway/run-app.sh manually on the command line from the home directory, the final returned line is:

/home/pi/webthings/gateway/run-app.sh: line 50: ./tools/post-upgrade.sh: No such file or directory

If I go to the webthings/gateway directory and run it from there, that error doesn’t appear (there is a file webthings/gateway/tools/post-upgrade.sh). Here is the final section of the output when running from there. The output was quite long – let me know if you want to see it all and I will post. The gateway still hasn’t started and there is no new run-app.log.

Segmentation fault
+ NVM_NPM_PREFIX=
+ nvm_tree_contains_path /home/pi/.nvm
+ [ _0 = _1 ]
+ nvm deactivate
+ nvm_err nvm is not compatible with the npm config “prefix” option: currently set to “”
+ nvm_echo nvm is not compatible with the npm config “prefix” option: currently set to “”
+ command printf %s\n nvm is not compatible with the npm config “prefix” option: currently set to “”
nvm is not compatible with the npm config “prefix” option: currently set to “”
+ nvm_has npm
+ type npm
+ nvm_err Run nvm use --delete-prefix v10.23.0 --silent to unset it.
+ nvm_echo Run nvm use --delete-prefix v10.23.0 --silent to unset it.
+ command printf %s\n Run nvm use --delete-prefix v10.23.0 --silent to unset it.
Run nvm use --delete-prefix v10.23.0 --silent to unset it.
+ return 10
+ return 11
+ EXIT_CODE=11
+ set -e
+ return 11

Sorry, I didn’t realise there were a bunch of relative paths in that shell script. What happens if you run it from its own directory?

$ cd ~/webthings/gateway
$ ./run-app.sh

The following is displayed:

  + WEBTHINGS_HOME=/home/pi/.webthings
    + args=
    + start_task=run-only
    + is_container
    + '[' -f /.dockerenv ']'
    + '[' -f /run/.containerenv ']'
    + grep -q ':\/docker\/' /proc/1/cgroup
    + '[' -d /pantavisor ']'
    + return 1
    + '[' '!' -f .post_upgrade_complete ']'
    + [[ /home/pi/.webthings == \/\h\o\m\e\/\p\i\/\.\w\e\b\t\h\i\n\g\s ]]
    + [[ -d /home/pi/.mozilla-iot ]]
    + mkdir -p /home/pi/.webthings/log
    + '[' -f /home/pi/.webthings/log/run-app.log ']'
    + run_app
    + export NVM_DIR=/home/pi/.nvm
    + NVM_DIR=/home/pi/.nvm
    + '[' '!' -s /home/pi/.nvm/nvm.sh ']'
    + . /home/pi/.nvm/nvm.sh
    ++ NVM_SCRIPT_SOURCE=']'
    ++ '[' -z '' ']'
    ++ export NVM_CD_FLAGS=
    ++ NVM_CD_FLAGS=
    ++ nvm_is_zsh
    ++ '[' -n '' ']'
    ++ '[' -z /home/pi/.nvm ']'
    ++ case $NVM_DIR in
    ++ unset NVM_SCRIPT_SOURCE
    ++ nvm_process_parameters
    ++ local NVM_AUTO_MODE
    ++ NVM_AUTO_MODE=use
    ++ nvm_supports_source_options
    +++ . /dev/stdin yes
    ++ '[' _yes = _yes ']'
    ++ '[' 0 -ne 0 ']'
    ++ nvm_auto use
    ++ local NVM_CURRENT
    +++ nvm_ls_current
    +++ local NVM_LS_CURRENT_NODE_PATH
    ++++ command which node
    +++ NVM_LS_CURRENT_NODE_PATH=
    +++ nvm_echo none
    +++ command printf '%s\n' none
    ++ NVM_CURRENT=none
    ++ local NVM_MODE
    ++ NVM_MODE=use
    ++ local VERSION
    ++ '[' _use = _install ']'
    ++ '[' _use = _use ']'
    ++ '[' _none = _none ']'
    +++ nvm_resolve_local_alias default
    ++ VERSION=v10.23.0
    ++ '[' -n v10.23.0 ']'
    ++ nvm use --silent v10.23.0
    ++ '[' 3 -lt 1 ']'
    ++ local DEFAULT_IFS
    +++ nvm_echo t
    +++ command printf '%s\n' t
    +++ command tr t '\t'
    +++ tr t '\t'
    ++ DEFAULT_IFS='
    '
    ++ '[' hxB '!=' ehxB ']'
    ++ set +e
    ++ local EXIT_CODE
    ++ IFS='
    '
    ++ nvm use --silent v10.23.0
    ++ '[' 3 -lt 1 ']'
    ++ local DEFAULT_IFS
    +++ nvm_echo t
    +++ command printf '%s\n' t
    +++ command tr t '\t'
    +++ tr t '\t'
    ++ DEFAULT_IFS='
    '
    ++ '[' hxB '!=' hxB ']'
    ++ '[' '
    ' '!=' '
    ' ']'
    ++ local COMMAND
    ++ COMMAND=use
    ++ shift
    ++ local VERSION
    ++ local ADDITIONAL_PARAMETERS
    ++ case $COMMAND in
    ++ local PROVIDED_VERSION
    ++ local NVM_USE_SILENT
    ++ NVM_USE_SILENT=0
    ++ local NVM_DELETE_PREFIX
    ++ NVM_DELETE_PREFIX=0
    ++ local NVM_LTS
    ++ '[' 2 -ne 0 ']'
    ++ case "$1" in
    ++ NVM_USE_SILENT=1
    ++ shift
    ++ '[' 1 -ne 0 ']'
    ++ case "$1" in
    ++ '[' -n v10.23.0 ']'
    ++ PROVIDED_VERSION=v10.23.0
    ++ shift
    ++ '[' 0 -ne 0 ']'
    ++ '[' -n '' ']'
    ++ '[' -z v10.23.0 ']'
    +++ nvm_match_version v10.23.0
    +++ local NVM_IOJS_PREFIX
    ++++ nvm_iojs_prefix
    ++++ nvm_echo iojs
    ++++ command printf '%s\n' iojs
    +++ NVM_IOJS_PREFIX=iojs
    +++ local PROVIDED_VERSION
    +++ PROVIDED_VERSION=v10.23.0
    +++ case "_${PROVIDED_VERSION}" in
    +++ nvm_version v10.23.0
    +++ local PATTERN
    +++ PATTERN=v10.23.0
    +++ local VERSION
    +++ '[' -z v10.23.0 ']'
    +++ '[' v10.23.0 = current ']'
    +++ local NVM_NODE_PREFIX
    ++++ nvm_node_prefix
    ++++ nvm_echo node
    ++++ command printf '%s\n' node
    +++ NVM_NODE_PREFIX=node
    +++ case "_${PATTERN}" in
    ++++ nvm_ls v10.23.0
    ++++ command tail -1
    ++++ tail -1
    ++++ local PATTERN
    ++++ PATTERN=v10.23.0
    ++++ local VERSIONS
    ++++ VERSIONS=
    ++++ '[' v10.23.0 = current ']'
    ++++ local NVM_IOJS_PREFIX
    +++++ nvm_iojs_prefix
    +++++ nvm_echo iojs
    +++++ command printf '%s\n' iojs
    ++++ NVM_IOJS_PREFIX=iojs
    ++++ local NVM_NODE_PREFIX
    +++++ nvm_node_prefix
    +++++ nvm_echo node
    +++++ command printf '%s\n' node
    ++++ NVM_NODE_PREFIX=node
    ++++ local NVM_VERSION_DIR_IOJS
    +++++ nvm_version_dir iojs
    +++++ local NVM_WHICH_DIR
    +++++ NVM_WHICH_DIR=iojs
    +++++ '[' -z iojs ']'
    +++++ '[' iojs = new ']'
    +++++ '[' _iojs = _iojs ']'
    +++++ nvm_echo /home/pi/.nvm/versions/io.js
    +++++ command printf '%s\n' /home/pi/.nvm/versions/io.js
    ++++ NVM_VERSION_DIR_IOJS=/home/pi/.nvm/versions/io.js
    ++++ local NVM_VERSION_DIR_NEW
    +++++ nvm_version_dir new
    +++++ local NVM_WHICH_DIR
    +++++ NVM_WHICH_DIR=new
    +++++ '[' -z new ']'
    +++++ '[' new = new ']'
    +++++ nvm_echo /home/pi/.nvm/versions/node
    +++++ command printf '%s\n' /home/pi/.nvm/versions/node
    ++++ NVM_VERSION_DIR_NEW=/home/pi/.nvm/versions/node
    ++++ local NVM_VERSION_DIR_OLD
    +++++ nvm_version_dir old
    +++++ local NVM_WHICH_DIR
    +++++ NVM_WHICH_DIR=old
    +++++ '[' -z old ']'
    +++++ '[' old = new ']'
    +++++ '[' _old = _iojs ']'
    +++++ '[' _old = _old ']'
    +++++ nvm_echo /home/pi/.nvm
    +++++ command printf '%s\n' /home/pi/.nvm
    ++++ NVM_VERSION_DIR_OLD=/home/pi/.nvm
    ++++ case "${PATTERN}" in
    ++++ nvm_resolve_local_alias v10.23.0
    ++++ '[' -z v10.23.0 ']'
    ++++ local VERSION
    ++++ local EXIT_CODE
    +++++ nvm_resolve_alias v10.23.0
    +++++ '[' -z v10.23.0 ']'
    +++++ local PATTERN
    +++++ PATTERN=v10.23.0
    +++++ local ALIAS
    +++++ ALIAS=v10.23.0
    +++++ local ALIAS_TEMP
    +++++ local SEEN_ALIASES
    +++++ SEEN_ALIASES=v10.23.0
    +++++ true
    ++++++ nvm_alias v10.23.0
    ++++++ nvm_echo
    ++++++ command printf '%s\n' ''
    +++++ ALIAS_TEMP=
    +++++ '[' -z '' ']'
    +++++ break
    +++++ '[' -n v10.23.0 ']'
    +++++ '[' _v10.23.0 '!=' _v10.23.0 ']'
    +++++ nvm_validate_implicit_alias v10.23.0
    +++++ return 2
    ++++ VERSION=
    ++++ EXIT_CODE=2
    ++++ '[' -z '' ']'
    ++++ return 2
    +++++ nvm_ensure_version_prefix v10.23.0
    +++++ local NVM_VERSION
    ++++++ nvm_strip_iojs_prefix v10.23.0
    ++++++ local NVM_IOJS_PREFIX
    ++++++ command sed -e 's/^\([0-9]\)/v\1/g'
    ++++++ sed -e 's/^\([0-9]\)/v\1/g'
    +++++++ nvm_iojs_prefix
    +++++++ nvm_echo iojs
    +++++++ command printf '%s\n' iojs
    ++++++ NVM_IOJS_PREFIX=iojs
    ++++++ '[' v10.23.0 = iojs ']'
    ++++++ nvm_echo v10.23.0
    ++++++ command printf '%s\n' v10.23.0
    +++++ NVM_VERSION=v10.23.0
    +++++ nvm_is_iojs_version v10.23.0
    +++++ case "${1-}" in
    +++++ return 1
    +++++ nvm_echo v10.23.0
    +++++ command printf '%s\n' v10.23.0
    ++++ PATTERN=v10.23.0
    ++++ '[' v10.23.0 = N/A ']'
    ++++ local NVM_PATTERN_STARTS_WITH_V
    ++++ case $PATTERN in
    ++++ NVM_PATTERN_STARTS_WITH_V=true
    ++++ '[' true = true ']'
    +++++ nvm_num_version_groups v10.23.0
    +++++ local VERSION
    +++++ VERSION=v10.23.0
    +++++ VERSION=10.23.0
    +++++ VERSION=10.23.0
    +++++ '[' -z 10.23.0 ']'
    +++++ local NVM_NUM_DOTS
    ++++++ nvm_echo 10.23.0
    ++++++ command printf '%s\n' 10.23.0
    ++++++ command sed -e 's/[^\.]//g'
    ++++++ sed -e 's/[^\.]//g'
    +++++ NVM_NUM_DOTS=..
    +++++ local NVM_NUM_GROUPS
    +++++ NVM_NUM_GROUPS=...
    +++++ nvm_echo 3
    +++++ command printf '%s\n' 3
    ++++ '[' _3 = _3 ']'
    ++++ nvm_is_version_installed v10.23.0
    ++++ '[' -n v10.23.0 ']'
    +++++ nvm_version_path v10.23.0
    ++++ '[' -x /home/pi/.nvm/versions/node/v10.23.0/bin/node ']'
    ++++ VERSIONS=v10.23.0
    ++++ '[' '' = true ']'
    ++++ '[' -z v10.23.0 ']'
    ++++ nvm_echo v10.23.0
    ++++ command printf '%s\n' v10.23.0
    +++ VERSION=v10.23.0
    +++ '[' -z v10.23.0 ']'
    +++ '[' _v10.23.0 = _N/A ']'
    +++ nvm_echo v10.23.0
    +++ command printf '%s\n' v10.23.0
    ++ VERSION=v10.23.0
    ++ '[' -z v10.23.0 ']'
    ++ '[' _v10.23.0 = _system ']'
    ++ '[' _v10.23.0 = _∞ ']'
    ++ '[' v10.23.0 = N/A ']'
    ++ nvm_ensure_version_installed v10.23.0
    ++ local PROVIDED_VERSION
    ++ PROVIDED_VERSION=v10.23.0
    ++ '[' v10.23.0 = system ']'
    ++ local LOCAL_VERSION
    ++ local EXIT_CODE
    +++ nvm_version v10.23.0
    +++ local PATTERN
    +++ PATTERN=v10.23.0
    +++ local VERSION
    +++ '[' -z v10.23.0 ']'
    +++ '[' v10.23.0 = current ']'
    +++ local NVM_NODE_PREFIX
    ++++ nvm_node_prefix
    ++++ nvm_echo node
    ++++ command printf '%s\n' node
    +++ NVM_NODE_PREFIX=node
    +++ case "_${PATTERN}" in
    ++++ nvm_ls v10.23.0
    ++++ command tail -1
    ++++ tail -1
    ++++ local PATTERN
    ++++ PATTERN=v10.23.0
    ++++ local VERSIONS
    ++++ VERSIONS=
    ++++ '[' v10.23.0 = current ']'
    ++++ local NVM_IOJS_PREFIX
    +++++ nvm_iojs_prefix
    +++++ nvm_echo iojs
    +++++ command printf '%s\n' iojs
    ++++ NVM_IOJS_PREFIX=iojs
    ++++ local NVM_NODE_PREFIX
    +++++ nvm_node_prefix
    +++++ nvm_echo node
    +++++ command printf '%s\n' node
    ++++ NVM_NODE_PREFIX=node
    ++++ local NVM_VERSION_DIR_IOJS
    +++++ nvm_version_dir iojs
    +++++ local NVM_WHICH_DIR
    +++++ NVM_WHICH_DIR=iojs
    +++++ '[' -z iojs ']'
    +++++ '[' iojs = new ']'
    +++++ '[' _iojs = _iojs ']'
    +++++ nvm_echo /home/pi/.nvm/versions/io.js
    +++++ command printf '%s\n' /home/pi/.nvm/versions/io.js
    ++++ NVM_VERSION_DIR_IOJS=/home/pi/.nvm/versions/io.js
    ++++ local NVM_VERSION_DIR_NEW
    +++++ nvm_version_dir new
    +++++ local NVM_WHICH_DIR
    +++++ NVM_WHICH_DIR=new
    +++++ '[' -z new ']'
    +++++ '[' new = new ']'
    +++++ nvm_echo /home/pi/.nvm/versions/node
    +++++ command printf '%s\n' /home/pi/.nvm/versions/node
    ++++ NVM_VERSION_DIR_NEW=/home/pi/.nvm/versions/node
    ++++ local NVM_VERSION_DIR_OLD
    +++++ nvm_version_dir old
    +++++ local NVM_WHICH_DIR
    +++++ NVM_WHICH_DIR=old
    +++++ '[' -z old ']'
    +++++ '[' old = new ']'
    +++++ '[' _old = _iojs ']'
    +++++ '[' _old = _old ']'
    +++++ nvm_echo /home/pi/.nvm
    +++++ command printf '%s\n' /home/pi/.nvm
    ++++ NVM_VERSION_DIR_OLD=/home/pi/.nvm
    ++++ case "${PATTERN}" in
    ++++ nvm_resolve_local_alias v10.23.0
    ++++ '[' -z v10.23.0 ']'
    ++++ local VERSION
    ++++ local EXIT_CODE
    +++++ nvm_resolve_alias v10.23.0
    +++++ '[' -z v10.23.0 ']'
    +++++ local PATTERN
    +++++ PATTERN=v10.23.0
    +++++ local ALIAS
    +++++ ALIAS=v10.23.0
    +++++ local ALIAS_TEMP
    +++++ local SEEN_ALIASES
    +++++ SEEN_ALIASES=v10.23.0
    +++++ true
    ++++++ nvm_alias v10.23.0
    ++++++ nvm_echo
    ++++++ command printf '%s\n' ''
    +++++ ALIAS_TEMP=
    +++++ '[' -z '' ']'
    +++++ break
    +++++ '[' -n v10.23.0 ']'
    +++++ '[' _v10.23.0 '!=' _v10.23.0 ']'
    +++++ nvm_validate_implicit_alias v10.23.0
    +++++ return 2
    ++++ VERSION=
    ++++ EXIT_CODE=2
    ++++ '[' -z '' ']'
    ++++ return 2
    +++++ nvm_ensure_version_prefix v10.23.0
    +++++ local NVM_VERSION
    ++++++ nvm_strip_iojs_prefix v10.23.0
    ++++++ local NVM_IOJS_PREFIX
    ++++++ command sed -e 's/^\([0-9]\)/v\1/g'
    ++++++ sed -e 's/^\([0-9]\)/v\1/g'
    +++++++ nvm_iojs_prefix
    +++++++ nvm_echo iojs
    +++++++ command printf '%s\n' iojs
    ++++++ NVM_IOJS_PREFIX=iojs
    ++++++ '[' v10.23.0 = iojs ']'
    ++++++ nvm_echo v10.23.0
    ++++++ command printf '%s\n' v10.23.0
    +++++ NVM_VERSION=v10.23.0
    +++++ nvm_is_iojs_version v10.23.0
    +++++ case "${1-}" in
    +++++ return 1
    +++++ nvm_echo v10.23.0
    +++++ command printf '%s\n' v10.23.0
    ++++ PATTERN=v10.23.0
    ++++ '[' v10.23.0 = N/A ']'
    ++++ local NVM_PATTERN_STARTS_WITH_V
    ++++ case $PATTERN in
    ++++ NVM_PATTERN_STARTS_WITH_V=true
    ++++ '[' true = true ']'
    +++++ nvm_num_version_groups v10.23.0
    +++++ local VERSION
    +++++ VERSION=v10.23.0
    +++++ VERSION=10.23.0
    +++++ VERSION=10.23.0
    +++++ '[' -z 10.23.0 ']'
    +++++ local NVM_NUM_DOTS
    ++++++ nvm_echo 10.23.0
    ++++++ command printf '%s\n' 10.23.0
    ++++++ command sed -e 's/[^\.]//g'
    ++++++ sed -e 's/[^\.]//g'
    +++++ NVM_NUM_DOTS=..
    +++++ local NVM_NUM_GROUPS
    +++++ NVM_NUM_GROUPS=...
    +++++ nvm_echo 3
    +++++ command printf '%s\n' 3
    ++++ '[' _3 = _3 ']'
    ++++ nvm_is_version_installed v10.23.0
    ++++ '[' -n v10.23.0 ']'
    +++++ nvm_version_path v10.23.0
    ++++ '[' -x /home/pi/.nvm/versions/node/v10.23.0/bin/node ']'
    ++++ VERSIONS=v10.23.0
    ++++ '[' '' = true ']'
    ++++ '[' -z v10.23.0 ']'
    ++++ nvm_echo v10.23.0
    ++++ command printf '%s\n' v10.23.0
    +++ VERSION=v10.23.0
    +++ '[' -z v10.23.0 ']'
    +++ '[' _v10.23.0 = _N/A ']'
    +++ nvm_echo v10.23.0
    +++ command printf '%s\n' v10.23.0
    ++ LOCAL_VERSION=v10.23.0
    ++ EXIT_CODE=0
    ++ local NVM_VERSION_DIR
    ++ '[' 0 '!=' 0 ']'
    ++ nvm_is_version_installed v10.23.0
    ++ '[' -n v10.23.0 ']'
    +++ nvm_version_path v10.23.0
    ++ '[' -x /home/pi/.nvm/versions/node/v10.23.0/bin/node ']'
    ++ local NVM_VERSION_DIR
    +++ nvm_version_path v10.23.0
    +++ local VERSION
    +++ VERSION=v10.23.0
    +++ '[' -z v10.23.0 ']'
    +++ nvm_is_iojs_version v10.23.0
    +++ case "${1-}" in
    +++ return 1
    +++ nvm_version_greater 0.12.0 v10.23.0
    +++ command awk 'BEGIN {
    if (ARGV[1] == "" || ARGV[2] == "") exit(1)
    split(ARGV[1], a, /\./);
    split(ARGV[2], b, /\./);
    for (i=1; i<=3; i++) {
      if (a[i] && a[i] !~ /^[0-9]+$/) exit(2);
      if (b[i] && b[i] !~ /^[0-9]+$/) { exit(0); }
      if (a[i] < b[i]) exit(3);
      else if (a[i] > b[i]) exit(0);
    }
    exit(4)
      }' 0.12.0 10.23.0
    +++ awk 'BEGIN {
    if (ARGV[1] == "" || ARGV[2] == "") exit(1)
    split(ARGV[1], a, /\./);
    split(ARGV[2], b, /\./);
    for (i=1; i<=3; i++) {
      if (a[i] && a[i] !~ /^[0-9]+$/) exit(2);
      if (b[i] && b[i] !~ /^[0-9]+$/) { exit(0); }
      if (a[i] < b[i]) exit(3);
      else if (a[i] > b[i]) exit(0);
    }
    exit(4)
      }' 0.12.0 10.23.0
    ++++ nvm_version_dir new
    ++++ local NVM_WHICH_DIR
    ++++ NVM_WHICH_DIR=new
    ++++ '[' -z new ']'
    ++++ '[' new = new ']'
    ++++ nvm_echo /home/pi/.nvm/versions/node
    ++++ command printf '%s\n' /home/pi/.nvm/versions/node
    +++ nvm_echo /home/pi/.nvm/versions/node/v10.23.0
    +++ command printf '%s\n' /home/pi/.nvm/versions/node/v10.23.0
    ++ NVM_VERSION_DIR=/home/pi/.nvm/versions/node/v10.23.0
    +++ nvm_change_path /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games /bin /home/pi/.nvm/versions/node/v10.23.0
    +++ '[' -z /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games ']'
    +++ nvm_echo /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
    +++ command printf '%s\n' /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
    +++ nvm_grep -q '/home/pi/.nvm/[^/]*/bin'
    +++ GREP_OPTIONS=
    +++ command grep -q '/home/pi/.nvm/[^/]*/bin'
    +++ grep -q '/home/pi/.nvm/[^/]*/bin'
    +++ nvm_echo /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
    +++ command printf '%s\n' /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
    +++ nvm_grep -q '/home/pi/.nvm/versions/[^/]*/[^/]*/bin'
    +++ GREP_OPTIONS=
    +++ command grep -q '/home/pi/.nvm/versions/[^/]*/[^/]*/bin'
    +++ grep -q '/home/pi/.nvm/versions/[^/]*/[^/]*/bin'
    +++ nvm_echo /home/pi/.nvm/versions/node/v10.23.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
    +++ command printf '%s\n' /home/pi/.nvm/versions/node/v10.23.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
    ++ PATH=/home/pi/.nvm/versions/node/v10.23.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
    ++ nvm_has manpath
    ++ type manpath
    ++ '[' -z '' ']'
    ++ local MANPATH
    +++ manpath
    ++ MANPATH=/home/pi/.nvm/versions/node/v10.23.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man
    +++ nvm_change_path /home/pi/.nvm/versions/node/v10.23.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man /share/man /home/pi/.nvm/versions/node/v10.23.0
    +++ '[' -z /home/pi/.nvm/versions/node/v10.23.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man ']'
    +++ nvm_echo /home/pi/.nvm/versions/node/v10.23.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man
    +++ command printf '%s\n' /home/pi/.nvm/versions/node/v10.23.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man
    +++ nvm_grep -q '/home/pi/.nvm/[^/]*/share/man'
    +++ GREP_OPTIONS=
    +++ command grep -q '/home/pi/.nvm/[^/]*/share/man'
    +++ grep -q '/home/pi/.nvm/[^/]*/share/man'
    +++ nvm_echo /home/pi/.nvm/versions/node/v10.23.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man
    +++ command printf '%s\n' /home/pi/.nvm/versions/node/v10.23.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man
    +++ nvm_grep -q '/home/pi/.nvm/versions/[^/]*/[^/]*/share/man'
    +++ GREP_OPTIONS=
    +++ command grep -q '/home/pi/.nvm/versions/[^/]*/[^/]*/share/man'
    +++ grep -q '/home/pi/.nvm/versions/[^/]*/[^/]*/share/man'
    +++ nvm_echo /home/pi/.nvm/versions/node/v10.23.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man
    +++ command printf '%s\n' /home/pi/.nvm/versions/node/v10.23.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man
    +++ nvm_grep -Eq '(^|:)(/usr(/local)?)?/share/man:.*/home/pi/.nvm/[^/]*/share/man'
    +++ GREP_OPTIONS=
    +++ command grep -Eq '(^|:)(/usr(/local)?)?/share/man:.*/home/pi/.nvm/[^/]*/share/man'
    +++ grep -Eq '(^|:)(/usr(/local)?)?/share/man:.*/home/pi/.nvm/[^/]*/share/man'
    +++ nvm_echo /home/pi/.nvm/versions/node/v10.23.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man
    +++ command printf '%s\n' /home/pi/.nvm/versions/node/v10.23.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man
    +++ nvm_grep -Eq '(^|:)(/usr(/local)?)?/share/man:.*/home/pi/.nvm/versions/[^/]*/[^/]*/share/man'
    +++ GREP_OPTIONS=
    +++ command grep -Eq '(^|:)(/usr(/local)?)?/share/man:.*/home/pi/.nvm/versions/[^/]*/[^/]*/share/man'
    +++ grep -Eq '(^|:)(/usr(/local)?)?/share/man:.*/home/pi/.nvm/versions/[^/]*/[^/]*/share/man'
    +++ nvm_echo /home/pi/.nvm/versions/node/v10.23.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man
    +++ command printf '%s\n' /home/pi/.nvm/versions/node/v10.23.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man
    +++ command sed -e 's#/home/pi/.nvm/[^/]*/share/man[^:]*#/home/pi/.nvm/versions/node/v10.23.0/share/man#' -e 's#/home/pi/.nvm/versions/[^/]*/[^/]*/share/man[^:]*#/home/pi/.nvm/versions/node/v10.23.0/share/man#'
    +++ sed -e 's#/home/pi/.nvm/[^/]*/share/man[^:]*#/home/pi/.nvm/versions/node/v10.23.0/share/man#' -e 's#/home/pi/.nvm/versions/[^/]*/[^/]*/share/man[^:]*#/home/pi/.nvm/versions/node/v10.23.0/share/man#'
    ++ MANPATH=/home/pi/.nvm/versions/node/v10.23.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man
    ++ export MANPATH
    ++ export PATH
    ++ hash -r
    ++ export NVM_BIN=/home/pi/.nvm/versions/node/v10.23.0/bin
    ++ NVM_BIN=/home/pi/.nvm/versions/node/v10.23.0/bin
    ++ '[' '' = true ']'
    ++ local NVM_USE_OUTPUT
    ++ NVM_USE_OUTPUT=
    ++ '[' 1 -ne 1 ']'
    ++ '[' _v10.23.0 '!=' _system ']'
    ++ local NVM_USE_CMD
    ++ NVM_USE_CMD='nvm use --delete-prefix'
    ++ '[' -n v10.23.0 ']'
    ++ NVM_USE_CMD='nvm use --delete-prefix v10.23.0'
    ++ '[' 1 -eq 1 ']'
    ++ NVM_USE_CMD='nvm use --delete-prefix v10.23.0 --silent'
    ++ nvm_die_on_prefix 0 'nvm use --delete-prefix v10.23.0 --silent'
    ++ local NVM_DELETE_PREFIX
    ++ NVM_DELETE_PREFIX=0
    ++ case "${NVM_DELETE_PREFIX}" in
    ++ local NVM_COMMAND
    ++ NVM_COMMAND='nvm use --delete-prefix v10.23.0 --silent'
    ++ '[' -z 'nvm use --delete-prefix v10.23.0 --silent' ']'
    ++ '[' -n '' ']'
    ++ local NVM_NPM_CONFIG_PREFIX_ENV
    +++ command env
    +++ env
    +++ nvm_grep -i NPM_CONFIG_PREFIX
    +++ GREP_OPTIONS=
    +++ command grep -i NPM_CONFIG_PREFIX
    +++ grep -i NPM_CONFIG_PREFIX
    +++ command tail -1
    +++ tail -1
    +++ command awk -F = '{print $1}'
    +++ awk -F = '{print $1}'
    ++ NVM_NPM_CONFIG_PREFIX_ENV=
    ++ '[' -n '' ']'
    ++ nvm_has npm
    ++ type npm
    ++ local NVM_NPM_PREFIX
    +++ npm config --loglevel=warn get prefix
    ++ NVM_NPM_PREFIX=
    ++ nvm_tree_contains_path /home/pi/.nvm ''
    ++ '[' _0 = _1 ']'
    ++ nvm deactivate
    ++ nvm_err 'nvm is not compatible with the npm config "prefix" option: currently set to ""'
    ++ nvm_echo 'nvm is not compatible with the npm config "prefix" option: currently set to ""'
    ++ command printf '%s\n' 'nvm is not compatible with the npm config "prefix" option: currently set to ""'
    nvm is not compatible with the npm config "prefix" option: currently set to ""
    ++ nvm_has npm
    ++ type npm
    ++ nvm_err 'Run `nvm use --delete-prefix v10.23.0 --silent` to unset it.'
    ++ nvm_echo 'Run `nvm use --delete-prefix v10.23.0 --silent` to unset it.'
    ++ command printf '%s\n' 'Run `nvm use --delete-prefix v10.23.0 --silent` to unset it.'
    Run `nvm use --delete-prefix v10.23.0 --silent` to unset it.
    ++ return 10
    ++ return 11
    ++ EXIT_CODE=11
    ++ set -e
    ++ return 11

Don’t know why or even if there is a mis-match in libraries. I googled the message in the log you posted and found this:

Thanks Eric (and for your earlier input, as well). A lot of this is beyond my knowledge and skills, as you’ve probably realised!

I’ve noticed that error is also showing when I first ssh into the r-pi.

nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v10.23.0 --silent` to unset it.

Does this mean I should run that command? And/or should I try the suggested solution in the link you provided:

$ npm config delete prefix 
$ npm config set prefix $NVM_DIR/versions/node/v10.23.0

I want to make sure I’m not going to make the problem worse!

I am not a node/npm/nvm expert, or even use the tools, but know enough that there appears to be a program version mis-match. In the URL above, this can occur when multiple different version of programs are installed by different applications or when you manually “upgrade” software versions. Often, one tool, nvm in this case depends on specific versions of nvm.

I think that the recommended command would remove an version that is not compatible, as the note says :slight_smile:

I however can’t say what other applications may be affected. Maybe the real developers will comment.

Here’s the result of running the command in the error message, returns ‘Segmentation fault’. I notice as well that there are two version folders.

pi@webthings:~/.nvm/versions/node $ ls -a
.  ..  v10.19.0  v10.23.0
pi@webthings:~/.nvm/versions/node $ nvm use --delete-prefix v10.23.0 --silent
Segmentation fault
pi@webthings:~/.nvm/versions/node $

@bfrancis or @mrstegeman, any suggestions of what to try next?

Is it possible that you have a bad SD card?

My initial reaction was: Of course it’s possible!

After some digging, found that one of the main reasons that a Pi’s SD card can become corrupted is repeated powering off/on from the switch, which is what I’ve been doing when my router mysteriously loses connection with the gateway. I noted this problem in my initial post, but not that my restart was via power switch – this might have got us to the solution more quickly!

I tried unsuccessfully to fix any corruption with fsck and related methods. fsck did find and supposedly fix a problem, but rebooting didn’t get the gateway running.

Anyway, I’m going to assume that a corruption is the problem. So when I came to a dead-end (for me) trying to fix it, I decided to just start again and reflash the SD card.

Let’s consider this (re)solved! And if I have the issue of the router disconnecting from the gateway, I’ll connect directly into the Pi to reboot and try to work out why that is happening.

Thanks all for your help.

FYI, in another of my previous posts about running the GW on a RPI, I mentioned I use the Docker image, but also that I mount a USB stick on boot and map a folder on the USB stick to install/store WebThing data. This prevents excessive writing on the SD card causing premature failure. A couple times a year, I manually shut down the RPI and can peform a “backup” of the USB card. You can google posts about RPI that describe how to move other “logfiles” to the USB and further reduce SD card writes. Finally, I remember reading a nice article about USB thumb drives with “better” chips in them intended for higher-write applicaitons that I’ve not investigated in case you want to be anal about using the best…