Skylar-Tech / node-red-contrib-matrix-chat

Matrix chat server support for Node-RED
GNU General Public License v3.0
31 stars 10 forks source link

Connection to Matrix server lost #82

Closed astriffe closed 1 year ago

astriffe commented 1 year ago

Hi everyone!

First of all, thanks a lot for your work in creating this awesome plugin -- highly appreciated!

For some time now -- I suspect it correlates with my update to nodered 3.0.2 -- my Matrix server connection is established at first but 30 seconds later closed again. This leads to (1) a malfunctioning matrix client of course and (2) to a memory leak.

11 Mar 11:49:04 - [info] Starting flows
11 Mar 11:49:05 - [info] [matrix-server-config:xxx Nodered] Initializing Matrix Server Config node
11 Mar 11:49:05 - [info] Started flows
11 Mar 11:49:06 - [info] [mqtt-broker:Mosquitto LOCAL] Connected to broker: mqtt://xxx.x.x.xxx:1883
11 Mar 11:49:08 - [info] [mqtt-broker:HiveMQ PUBLIC] Connected to broker: mqtt://broker.hivemq.com:1883
11 Mar 11:49:08 - [info] [matrix-server-config:xxx Nodered] Initializing crypto...
11 Mar 11:49:08 - [info] [mqtt-broker:HiveMQ private] Connected to broker: mqtts://some-id.s1.eu.hivemq.cloud:8883
11 Mar 11:49:12 - [info] [matrix-server-config:Alindy Nodered] Connecting to Matrix server...
11 Mar 11:49:14 - [info] [matrix-server-config:Alindy Nodered] Matrix client connected
11 Mar 11:49:14 - [info] [matrix-server-config:Alindy Nodered] Matrix server connection ready.
11 Mar 11:49:44 - [error] [matrix-server-config:Alindy Nodered] Connection to Matrix server lost

It is sufficient to only have a client configuration activated, there's no difference whether I add receiver/sender nodes or not. matrix-client-configuration

Are there others observing the same behaviour? Do you have an Idea where to look for the problem?

Thanks a lot, Alex

skylord123 commented 1 year ago

Hmm that is strange. I have been running it on Node-RED version 3.0.2 without any issues. Did you install any other modules around the time the issue came up? Sometimes other modules can cause issues.

https://matrix.org/.well-known/matrix/server

Have you tried using the URL that this returns? If not try https://matrix-federation.matrix.org and see if that works. They may have changed the URL for the public matrix server since you last set it up.

astriffe commented 1 year ago

Thanks a lot @skylord123 for your response.

The URL doesn't make a difference, unfortunately. Plus, an outdated/wrong URL logs a (different) error immediately.

I've

Yet, the issue persists:

Welcome to Node-RED
===================
12 Mar 12:17:19 - [info] Node-RED version: v3.0.2
12 Mar 12:17:19 - [info] Node.js  version: v18.14.1
12 Mar 12:17:19 - [info] Linux 5.15.84-v7+ arm LE
12 Mar 12:17:24 - [info] Loading palette nodes
12 Mar 12:17:27 - [debug] Module: node-red-contrib-influxdb 0.6.1 /home/pi/.node-red/node_modules/node-red-contrib-influxdb
12 Mar 12:17:27 - [debug] Module: node-red-contrib-matrix-chat 0.7.0 /home/pi/.node-red/node_modules/node-red-contrib-matrix-chat
12 Mar 12:17:27 - [debug] Module: node-red-contrib-nextcloud 0.1.3 /home/pi/.node-red/node_modules/node-red-contrib-nextcloud
12 Mar 12:17:27 - [debug] Module: node-red-contrib-shelly 10.13.1 /home/pi/.node-red/node_modules/node-red-contrib-shelly
12 Mar 12:17:27 - [debug] Module: node-red-contrib-sunevents 3.1.1 /home/pi/.node-red/node_modules/node-red-contrib-sunevents
12 Mar 12:17:27 - [debug] Module: node-red-contrib-wait-paths 0.3.2 /home/pi/.node-red/node_modules/node-red-contrib-wait-paths
12 Mar 12:17:27 - [debug] Module: node-red-dashboard 3.3.1 /home/pi/.node-red/node_modules/node-red-dashboard
12 Mar 12:17:27 - [debug] Module: node-red-node-ping 0.3.3 /home/pi/.node-red/node_modules/node-red-node-ping
12 Mar 12:17:27 - [debug] Module: node-red-node-smooth 0.1.2 /home/pi/.node-red/node_modules/node-red-node-smooth
12 Mar 12:17:27 - [debug] Module: node-red-node-tail 0.4.0 /home/pi/.node-red/node_modules/node-red-node-tail
12 Mar 12:17:37 - [info] Dashboard version 3.3.1 started at /ui
12 Mar 12:17:37 - [info] Settings file  : /home/pi/.node-red/settings.js
12 Mar 12:17:37 - [info] Context store  : 'default' [module=memory]
12 Mar 12:17:37 - [info] User directory : /home/pi/.node-red
12 Mar 12:17:37 - [warn] Projects disabled : editorTheme.projects.enabled=false
12 Mar 12:17:37 - [warn] Flows file name not set. Generating name using hostname.
12 Mar 12:17:37 - [info] Flows file     : /home/pi/.node-red/flows_chopin.json
12 Mar 12:17:38 - [info] Server now running at http://127.0.0.1:1880/
12 Mar 12:17:38 - [debug] loaded flow revision: 3ac5dabc75e6d76d8dc8da16c4d7cefb
12 Mar 12:17:38 - [info] Starting flows
12 Mar 12:17:38 - [debug] red/nodes/flows.start : starting flow : global
12 Mar 12:17:38 - [debug] red/nodes/flows.start : starting flow : f83b7bb1.92a87
12 Mar 12:17:38 - [info] [matrix-server-config:matrix-connection] Initializing Matrix Server Config node
12 Mar 12:17:40 - [debug] [inject:eda0a0920e154f4d] crontab = 00 18 * * *
12 Mar 12:17:40 - [info] Started flows
12 Mar 12:17:41 - [info] [mqtt-broker:Mosquitto LOCAL] Connected to broker: mqtt://xxx.x.x.x:1883
12 Mar 12:17:42 - [info] [mqtt-broker:HiveMQ PUBLIC] Connected to broker: mqtt://broker.hivemq.com:1883
12 Mar 12:17:43 - [info] [mqtt-broker:HiveMQ private] Connected to broker: mqtts://xxxx.s1.eu.hivemq.cloud:8883
12 Mar 12:17:44 - [info] [matrix-server-config:matrix-connection] Initializing crypto...
12 Mar 12:17:47 - [info] [matrix-server-config:matrix-connection] Connecting to Matrix server...
12 Mar 12:17:49 - [debug] [matrix-server-config:matrix-connection] SYNC [STATE=PREPARED] [PREVSTATE=null]
12 Mar 12:17:49 - [info] [matrix-server-config:matrix-connection] Matrix client connected
12 Mar 12:17:49 - [info] [matrix-server-config:matrix-connection] Matrix server connection ready.
12 Mar 12:17:49 - [debug] [matrix-server-config:matrix-connection] SYNC [STATE=SYNCING] [PREVSTATE=PREPARED]
12 Mar 12:17:49 - [debug] [inject:halbstündlich] repeat = 1800000
12 Mar 12:18:19 - [debug] [matrix-server-config:matrix-connection] SYNC [STATE=RECONNECTING] [PREVSTATE=SYNCING]
12 Mar 12:18:19 - [error] [matrix-server-config:matrix-connection] Connection to Matrix server lost
12 Mar 12:18:22 - [debug] [matrix-server-config:matrix-connection] SYNC [STATE=SYNCING] [PREVSTATE=RECONNECTING]
12 Mar 12:18:52 - [debug] [matrix-server-config:matrix-connection] SYNC [STATE=SYNCING] [PREVSTATE=SYNCING]
12 Mar 12:18:52 - [info] [matrix-server-config:matrix-connection] Matrix client connected
12 Mar 12:18:52 - [info] [matrix-server-config:matrix-connection] Matrix server connection ready.
12 Mar 12:19:22 - [debug] [matrix-server-config:matrix-connection] SYNC [STATE=RECONNECTING] [PREVSTATE=SYNCING]
12 Mar 12:19:22 - [error] [matrix-server-config:matrix-connection] Connection to Matrix server lost
12 Mar 12:19:25 - [debug] [matrix-server-config:matrix-connection] SYNC [STATE=SYNCING] [PREVSTATE=RE

Trace logging doesn't bring anything new. I'll keep you posted if I find out anything new :)

astriffe commented 1 year ago

ok -- seems like in the end I additionally messed up encryption completely :)

It's working again, yet I can't clearly point to the single point causing trouble. Please excuse the hassle...

SoftwareSchlosser commented 1 year ago

I have the same problem.

When trying to fetch a new auth token i get this error after a while:

Auth check failed: ConnectionError: fetch failed: request to https://<my_server url>/_matrix/client/r0/account/whoami failed, reason: connect ETIMEDOUT <my_server ip>:443"

I didn't change anything (node / modules etc) as far as i can remember. It's just somewhat confusing to me that ist states the url and then the ip but that might be just the way it logs.

Of course all other clients in my network can use the server as usual.

skylord123 commented 1 year ago

@SoftwareSchlosser have you tried restarting node-red? Also what versions are you on?

I sometimes have issues with node-red not reconnecting after I lose internet and it comes back. If restarting it fixes it you may have the same issue.

Also is this a Synapse server or another type?

SoftwareSchlosser commented 1 year ago

@skylord123 Yes, restarting didn't help.

Node is version 16.19.1 Node-RED is version 3.0.2. Plugin is latest version (0.7.0). And it's a synapse server (1.79).

skylord123 commented 1 year ago

@SoftwareSchlosser I will test these versions locally to see if I can find anything.

In the mean time can you list out what other modules you have installed? It would also be nice if you could try running with just this module installed and see if the issue persists. Wondering if another package is causing a conflict. If you have a lot of flows using other nodes and don't want to remove then you could also install another Node-RED instance and try it there (just make sure you use another Matrix user so you don't break encryption, but if you aren't using encryption it shouldn't matter).

skylord123 commented 1 year ago

@SoftwareSchlosser I used the same versions and could not replicate this. I'm wondering if this is a compatibility issue with another module you installed.

SoftwareSchlosser commented 1 year ago

Sorry for the late answer. For some reason it just works again and I have no idea why o0

skylord123 commented 1 year ago

For some reason it just works again and I have no idea why o0

Hey don't be sorry. Several people have reported this so it most likely is an issue. It's just strange that it keeps resolving itself. There has to be something that is changing..

EDIT: Did you restart the machine or docker service before it started working again?