jooola / zabbix-matrix-webhook

GNU General Public License v3.0
36 stars 8 forks source link

Request failed: 403 Unknown room #8

Closed Killerhaschen closed 3 years ago

Killerhaschen commented 3 years ago

Hi i imported the settings and then added a room ID of type "!xxxxxxxx:server.domain.tld", and then the Serve "https://server.domain.tld" and the token. But if i test it i will always get the error:

Media type test failed.
Sending failed: Request failed: 403 Unknown room

What am id doing wrong?

jooola commented 3 years ago

On the top of my head I would say your Room ID is not right. You probably added the matrix server URL to the Room ID, which is probably the cause of the failure.

Use !xxxx instead of !xxxx:server.domain.tld

jooola commented 3 years ago

Hey, discard everything I just said, I am not totally awake today.

jooola commented 3 years ago

So I think I need more info about you issue in order to have an idea of what is going on.

Killerhaschen commented 3 years ago

I use Zabbix and Matrix on one Server as Doker Containers behind a reverse Proxy that uses Letsencrypt Certificates. I tested:

00:00:00.000 [Debug] [Matrix Webhook] new request to: https://server.domain.tld/_matrix/client/r0/rooms/{ALERT.SENDTO}/send/m.room.message
00:00:00.055 [Debug] [Matrix Webhook] Request failed: Unknown room
00:00:00.057 [Debug] [Matrix Webhook] Error: Request failed: 403 Unknown room
Killerhaschen commented 3 years ago

Is there anything else i can upload that could help ?

jooola commented 3 years ago

The logs are always a good thing to share, you should have started with that.

Something is wrong in your configuration, the room ID is not properly set. Check your configuration again and be sure to either put the room ID in your users media settings or globally in the matrix webhook settings.

Killerhaschen commented 3 years ago

I cloud only Provide the full Zabbix Container log and that is huge, because there i monitor a lot ob websides and every response is conpletly in the logs. Do you have any idea how i can stop this? Setting it Globaly works for me. I dublicated the working profile and testet it again, if i try to get the roomID from the User it fails.

I tried to add the room to the error by changing th last lines of the script to:

} catch (error) {
    Zabbix.Log(4, '[Matrix Webhook] Error: ' + error)
    throw 'Sending failed: ' + error + 'room:'+ Matrix.room
}

That results to this error: Sending failed: Request failed: 403 Unknown roomroom:{ALERT.SENDTO} So it seems, that its not replaces by the Uservalue.

jooola commented 3 years ago

I cloud only Provide the full Zabbix Container log and that is huge, because there i monitor a lot ob websides and every response is conpletly in the logs. Do you have any idea how i can stop this?

This is not in the scope of this ticket, please search the internet.

I tried to add the room to the error by changing th last lines of the script to:

The first logs already provide this information, the {ALERT.SENDTO} entry defined in the users media settings, is supposed to be replaced by the roomID:

00:00:00.000 [Debug] [Matrix Webhook] new request to: https://server.domain.tld/_matrix/client/r0/rooms/{ALERT.SENDTO}/send/m.room.message
00:00:00.055 [Debug] [Matrix Webhook] Request failed: Unknown room
00:00:00.057 [Debug] [Matrix Webhook] Error: Request failed: 403 Unknown room

Please read the zabbix documentation about webhooks, and about testing webhooks: https://www.zabbix.com/documentation/current/manual/config/notifications/media/webhook

Here is how my user media settings are: The send to image

jooola commented 3 years ago

See https://github.com/jooola/zabbix-matrix-webhook#zabbix-webhook-configuration

Killerhaschen commented 3 years ago

The problem was my misconfiguration of zabbix. I did not knew, that a trigger goes to an action that sends the message. I configured my action "Report problems to Zabbix administrators" in the "Operations" to "Send only to" Telegram. That was why never a message over matrix was sent. For any reason set "Send only to" to all did not work for me. So i have now many Operations :D