Open woody4165 opened 2 weeks ago
What can I check/do?
You missed the pipe symbol for the template in the webhook notifier, it should look like:
...
webhook:
enabled: true
server: http://xxxxxxx:1880/webhook-frigate
header:
Content-Type: "application/json"
template: |
camera: "{{ .Camera }}"
label: "{{ .Label }}"
id: "{{ .ID }}"
See more: https://yaml-multiline.info/
Thanks @freefd
Strangely was working, not all the times maybe.
Now I've placed the pipe after the template:
and I will check it asap
@freefd After adding the pipe I get this error while loading the config
Failed to load config from file! error="1 error(s) decoding:\n\n* 'alerts.webhook.template' expected a map, got 'string'"
I've also placed correctly the indentation
template: |
camera: "{{ .Camera }}"
label: "{{ .Label }}"
id: "{{ .ID }}"
If I remove the pipe, the config loads correctly and I get the proper webhook in nodered
'alerts.webhook.template' expected a map, got 'string'"
And now we need to summon @0x2142 here.
Hi, So for the moment, there are two ways of configuring a custom webhook payload via template.
The first is what you've already tried - which is providing a mapping of key / value pairs:
template:
camera: "{{ .Camera }}"
Which then generates a message like:
{ "camera": "test_cam" }
Alternatively, you can enter a full JSON string, but at the moment it must be on one line:
template: { "camera": "{{ .Camera }}" }
Which would generate the same payload as above.
Looks like because of the way I've implemented this, the typical YAML multiline string input isn't working - so I'll have to figure out a way to address that. I should also update the docs to add more info about this one, since it's a bit different than the other notification providers.
Ok, thanks @0x2142
So, my configutation, that is lile the first one, is correct
My issue, I don't know if is an issue, is the warning messages that I always get that are like
2024/11/04 19:18:02 +0100 WRN util/httpclient.go:192 > HTTP Request failed, retrying in 10 seconds... error="Post \"http://192.168.1.160:1880/webhook-frigate\": http: ContentLength=70 with Body length 0" attempt=4 max_tries=6
2024/11/04 19:18:03 +0100 WRN util/httpclient.go:192 > HTTP Request failed, retrying in 10 seconds... error="Post \"http://192.168.1.160:1880/webhook-frigate\": http: ContentLength=70 with Body length 0" attempt=5 max_tries=6
2024/11/04 19:18:04 +0100 WRN util/httpclient.go:185 > HTTP Request failed, retries exceeded error="Post \"http://192.168.1.160:1880/webhook-frigate\": http: ContentLength=70 with Body length 0" attempt=6 max_tries=6
2024/11/04 19:18:04 +0100 WRN notifier/webhook.go:53 > Unable to send alert error="Post \"http://192.168.1.160:1880/webhook-frigate\": http: ContentLength=70 with Body length 0" event_id=1730744265.934368-b50rn7 provider=Webhook
They are just warning or should I worry about?
Hi @woody4165 - So, there are two things going on here...
First, I tried spinning up a node red instance to see if I can replicate this - and sure enough it was pretty easy. I've never used node red before, so I added an "http in" for the incoming webhook, then some logic after to forward the request elsewhere. It looks like with this config, node red never responds to frigate-notify - so the app sits there until the request times out, which then initiates he retry errors you're seeing.
In order to fix this, I needed to add a "http response" with a status code of 200. Seems like without this, node red never responds with a status code - so the connection just hangs and times out.
Here's what my quick flow looks like:
So perhaps this might be your issue as well? If so, you should just need to add a response to the initial inbound webhook from frigate-notify.
Second - the warnings you are getting are in fact a bug in the HTTP retry logic. I'll get this resolved in the next release.
ContentLength=66 with Body length 0
@0x2142 I'm more worried about this one ^^^
@woody4165 can you please run your Frigate-notify instance in the trace logging mode (https://frigate-notify.0x2142.com/latest/config/options/) and provide more logs about the request? Based on your configuration this code will be invoked: https://github.com/0x2142/frigate-notify/blob/main/notifier/webhook.go#L45 And thus the entire request will be logged by https://github.com/0x2142/frigate-notify/blob/main/util/httpclient.go#L158-L163 lines.
@freefd Yeah that's the issue I found. I'm not handling the request body properly in the retry, so once that first request is sent, subsequent retries are actually sending an empty body. I have a fix already in my current local branch & it will be out in the dev
branch for you soon 😊
@0x2142, oh... got the problem. @woody4165, please ignore my request about the trace log level.
So perhaps this might be your issue as well? If so, you should just need to add a response to the initial inbound webhook from frigate-notify.
Thanks @0x2142 I've just added an http response node with 200 and I'll check with next motion
My flow does not include http request node, since I get the data sent from the webhook directly from http in node
@freefd thanks for your suggestion, I'll wait for your fix
@0x2142 , @freefd It seems that all the webhook warnings are gone So I've just added the http response node with 200 as value
Thanks !
Just one more question, not related to webhook, in case it's needed I'll open a new issue
Some times, most of the times, I get two telegram message for same event, one without the event clips link, one with. The sent snapshots are almost the same, maybe some frame later the second message. Is it possible to avoid the message without the clip?
@woody4165 I wrote the message about this behavior but finally decided to ask you to create a new issue so as not to mix topics, please.
Hi @freefd
let me know if I can close this issue, since now it seems that everything is ok
@woody4165, perhaps @0x2142 might want to make some commits with this issue as the ref, and close it after fixing, idk.
Hi
I have set webhook alerts and I get several WARN in the log
This is part of the log with warnings
and this is my configuration
What can I check/do?
Thanks