can not get matrix notifications to work

I have created a Natrix user for this purpose and retrieved the access token as described at Send Netdata notifications to Matrix network rooms | Learn Netdata. My configuration looks like this:

MATRIX_HOMESERVER=“https://chat.mstdn.social:8448
MATRIX_ACCESSTOKEN=“mytoken”
DEFAULT_RECIPIENT_MATRIX=“!myroomid:mstdn.social”

When I want to test notifications, netdata just hangs at: SENDING TEST WARNING ALARM TO ROLE: sysadmin

Did anyone get Matrix notifications to work or did I do something wrong?

Hi, @hario. Can you run the script with debug enabled:

NETDATA_ALARM_NOTIFY_DEBUG=1 ./alarm-notify.sh test

Hi @ilyam8

Sure. Here is the output with debug enabled:

2022-08-16 20:45:09: alarm-notify.sh: DEBUG: Loading config file ‘/usr/lib/netdata/conf.d/health_alarm_notify.conf’…
2022-08-16 20:45:09: alarm-notify.sh: DEBUG: Loading config file ‘/etc/netdata/health_alarm_notify.conf’…
2022-08-16 20:45:09: alarm-notify.sh: DEBUG: Cannot find sendmail command in the system path. Disabling email notifications.
2022-08-16 20:45:09: alarm-notify.sh: DEBUG: Cannot find aws command in the system path. Disabling Amazon SNS notifications.
— BEGIN curl command —
/usr/bin/curl -X POST --data $’ {\n “msgtype”: “m.notice”,\n “format”: “org.matrix.custom.html”,\n “formatted_body”: “\342\232\240\357\270\217 quassel needs attention - test alarm
test.chart (test.family)
<a href=\“https://app.netdata.cloud/alarms/redirect?agentId=59692f0e-18c1-11ed-a7bf-6d496d456fdf&host=quassel&chart=test.chart&family=test.family&alarm=test_alarm&alarm_unique_id=1&alarm_id=1&alarm_event_id=1&alarm_when=1660675509&alarm_status=WARNING&alarm_chart=test.chart&alarm_value=new%20value\\”>test alarm = new value
this is a test alarm to verify notifications work”,\n “body”: “\342\232\240\357\270\217 quassel needs attention - test alarm test.chart (test.family) https://app.netdata.cloud/alarms/redirect?agentId=59692f0e-18c1-11ed-a7bf-6d496d456fdf&host=quassel&chart=test.chart&family=test.family&alarm=test_alarm&alarm_unique_id=1&alarm_id=1&alarm_event_id=1&alarm_when=1660675509&alarm_status=WARNING&alarm_chart=test.chart&alarm_value=new%20value test alarm = new value this is a test alarm to verify notifications work”\n }’ https://chat.mstdn.social:8448/_matrix/client/r0/rooms/!ROOMID%3Amstdn.social/send/m.room.message\?access_token=secrettoken
— END curl command —

After that it just hangs. However, I have already found a workaround. I send my alerts to an IRC server, which I can also easily join as a Matrix user.

It hangs on sending a message. I see we have no timeout set when using curl.

So Netdata tries to connect to

https://chat.mstdn.social:8448/_matrix/client/r0/rooms/!ROOMID%3Amstdn.social/send/m.room.message\?access_token=secrettoken

but the endpoint doesn’t respond.

1 Like

I made a PR that sets the connection timeout to 5 seconds.

1 Like

@hario just in case, I wasn’t clear: my PR just adds a timeout, so the health script fails earlier (doesn’t hang). It doesn’t fix your problem which is likely on your end (my understanding is that the endpoint doesn’t respond to Netdata’s attempt to connect (TCP SYN)).

I know it doesn’t solve my problem.
Nevertheless, you have helped me a lot and I know now that it is not because of netdata. So on the netdata side everything is fine.
I might analyze again why the Matrix endpoint is not responding, but alerts via IRC work fine too