webhook的message.acked触发不了,emqx版本4.4

on_client_connected和on_client_disconnected可以触发,acked事件触发不了

我的webhook配置:

##====================================================================
## WebHook
##====================================================================

## Webhook URL
##
## Value: String
web.hook.url = http://116.62.103.xxx:8081/mqtt/webhook

## HTTP Headers
##
## Example:
## 1. web.hook.headers.content-type = application/json
## 2. web.hook.headers.accept = *
##
## Value: String
web.hook.headers.content-type = application/json

## The encoding format of the payload field in the HTTP body
## The payload field only appears in the on_message_publish and on_message_delivered actions
##
## Value: plain | base64 | base62
web.hook.body.encoding_of_payload_field = plain

##--------------------------------------------------------------------
## PEM format file of CA's
##
## Value: File
## web.hook.ssl.cacertfile  = <PEM format file of CA's>

## Certificate file to use, PEM format assumed
##
## Value: File
## web.hook.ssl.certfile = <Certificate file to use>

## Private key file to use, PEM format assumed
##
## Value: File
## web.hook.ssl.keyfile = <Private key file to use>

## Turn on peer certificate verification
##
## Value: true | false
## web.hook.ssl.verify = false

## If not specified, the server's names returned in server's certificate is validated against
## what's provided `web.hook.url` config's host part.
## Setting to 'disable' will make EMQX ignore unmatched server names.
## If set with a host name, the server's names returned in server's certificate is validated
## against this value.
##
## Value: String | disable
## web.hook.ssl.server_name_indication = disable

## Connection process pool size
##
## Value: Number
web.hook.pool_size = 32

## Whether to enable HTTP Pipelining
##
## See: https://en.wikipedia.org/wiki/HTTP_pipelining
web.hook.enable_pipelining = true

##--------------------------------------------------------------------
## Hook Rules
## These configuration items represent a list of events should be forwarded
##
## Format:
##   web.hook.rule.<HookName>.<No> = <Spec>
#web.hook.rule.client.connect.1       = {"action": "on_client_connect"}
#web.hook.rule.client.connack.1       = {"action": "on_client_connack"}
web.hook.rule.client.connected.1      = {"action": "on_client_connected"}
web.hook.rule.client.disconnected.1   = {"action": "on_client_disconnected"}
#web.hook.rule.client.subscribe.1     = {"action": "on_client_subscribe"}
#web.hook.rule.client.unsubscribe.1   = {"action": "on_client_unsubscribe"}
#web.hook.rule.session.subscribed.1   = {"action": "on_session_subscribed"}
#web.hook.rule.session.unsubscribed.1 = {"action": "on_session_unsubscribed"}
#web.hook.rule.session.terminated.1   = {"action": "on_session_terminated"}
#web.hook.rule.message.publish.1      = {"action": "on_message_publish"}
#web.hook.rule.message.delivered.1    = {"action": "on_message_delivered"}
web.hook.rule.message.acked.1         = {"action": "on_message_acked"}

message.acked 事件是在 EMQX 把消投递给客户端后收到应答后回调的。

检查下是否订阅和发布的 QoS 都大于 0 呢

订阅和发布的qos都是1

用的 emqx 具体版本是哪个?4.4.17 吗?我来试试看。

我用 4.4.18 试了一下,是可以收到的。MQTT 客户端,QoS1 订阅了 t/# 主题,然后给自己发送 QoS1 的 t/1 消息。

webhook 插件相关的代码已经很长时间没有动过了,4.4.10 之后应该都一样的:

====headers: #{<<"content-length">> => <<"222">>,
               <<"content-type">> => <<"application/json">>,
               <<"host">> => <<"127.0.0.1:9901">>}
====body: <<"{\"username\":\"emqx\",\"ts\":1683344280094,\"topic\":\"t\",\"retain\":false,\"qos\":1,\"payload\":\"ff\",\"node\":\"emqx@127.0.0.1\",\"from_username\":\"emqx\",\"from_client_id\":\"mqttx_2cd1ae91\",\"clientid\":\"mqttx_2cd1ae91\",\"action\":\"message_acked\"}">>

插件配置:

web.hook.rule.client.connected.1     = {"action": "on_client_connected"}
web.hook.rule.client.disconnected.1  = {"action": "on_client_disconnected"}
web.hook.rule.message.acked.1        = {"action": "on_message_acked"}

4.4.4的

换成4.4.18版本可以了

4.4.18版本支持message.dropped吗

不再这个配置里就是不支持的