我想试下 emqx 的 webhook 插件,但配置完以后无法启动,在网页上的错误弹窗显示的是 Request failed with status code 500,然后在服务器上直接启动( emqx_ctl plugins load emqx_web_hook )
结果还是报错:
Load plugin emqx_web_hook failed, cannot start plugin emqx_web_hook
所以想问下我配置文件和接口文档应该怎么改,下面是配置文件和接口文档
配置文件( emqx_web_hook.conf ):
web.hook.api.url = http://127.0.0.1:8080
## Encode message payload field
## Value: base64 | base62
## Default: undefined
## web.hook.encode_payload = base64
#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.created.1 = {"action": "on_session_created"}
#web.hook.rule.session.subscribed.1 = {"action": "on_session_subscribed"}
web.hook.rule.session.subscribed.1 = {"action": "kan/webHook"}
#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.deliver.1 = {"action": "on_message_deliver"}
#web.hook.rule.message.acked.1 = {"action": "on_message_acked"}
接口代码:
package com.kan.api.controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/webHook")
public class mqttController {
@RequestMapping
public void receiveWebHookData(@RequestBody String str){
System.out.println(str);
}
}