【问题标题】:Deliver message in VerneMQ webhooks在 VerneMQ webhook 中传递消息
【发布时间】:2020-05-25 03:05:01
【问题描述】:

我正在使用来自 VerneMQ 插件的演示 webhook (python)

但演示只有auth_on_register,auth_on_publishauth_on_subscribe

我的消息已通过所有链,但 sub 看不到来自 pub 的消息

hook: auth_on_register
data:  {'peer_addr': '192.168.122.1', 'peer_port': 52363, 'mountpoint': '', 'client_id': 'quan-client', 'username': 'quan1', 'password': '123', 'clean_session': True}
127.0.0.1:58109 - - [25/May/2020 02:40:49] "HTTP/1.1 POST /" - 200 OK
hook: auth_on_register
data:  {'peer_addr': '192.168.122.1', 'peer_port': 46091, 'mountpoint': '', 'client_id': 'quan-client', 'username': 'quan1', 'password': '123', 'cle
an_session': True}
127.0.0.1:60003 - - [25/May/2020 02:40:49] "HTTP/1.1 POST /" - 200 OK
hook: auth_on_publish
data:  {'username': 'quan1', 'mountpoint': '', 'client_id': 'quan-client', 'qos': 0, 'topic': 'a', 'payload': 'dGVzdA==', 'retain': False}
127.0.0.1:58109 - - [25/May/2020 02:40:49] "HTTP/1.1 POST /" - 200 OK
hook: auth_on_subscribe
data:  {'username': 'quan1', 'mountpoint': '', 'client_id': 'quan-client', 'topics': [{'topic': 'a', 'qos': 0}]}
127.0.0.1:58109 - - [25/May/2020 02:40:49] "HTTP/1.1 POST /" - 200 OK

我想我错过了on_deliver 链,但我在 python 中找不到任何示例,github 仅在 erlang https://github.com/vernemq/vernemq_dev/blob/master/src/on_deliver_hook.erl

问:python语言中有没有方法、函数可以将消息传递给sub?

【问题讨论】:

    标签: python erlang mqtt-vernemq


    【解决方案1】:

    请查看文档:https://docs.vernemq.com/plugindevelopment/webhookplugins 你需要做两件事:注册钩子,也就是告诉 VerneMQ 你想为on_deliver 钩子提供一个端点。您可以在vernemq.conf 文件中进行此注册,或从命令行动态进行。

    请注意,使用 WebHooks 您实现的是 WebHook 后端,而不是 Erlang 中的插件。您必须在 Python 后端添加功能,尊重给定的 JSON 接口。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-22
      • 1970-01-01
      相关资源
      最近更新 更多