打开webhook客户端连不上emqx服务器

环境信息

  • EMQ X 版本:emqx-centos7-4.3.2-amd64.zip
  • 操作系统及版本:centos7
  • 其他

问题描述

配置文件及日志

修改了 emqx_web_hook.conf 文件的

web.hook.url = http://msg-dev.lianwuzizai.com/api/web-hook/msg/webHook/ 地址
把注释的
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"}

打开了

下面是emqx 的日志

2021-06-06T16:01:18.617117+08:00 [error] 103.100.65.248:42231 [WebHook] HTTP request error: {shutdown,econnrefused}
2021-06-06T16:01:22.054088+08:00 [error] 103.100.65.248:42233 [Hooks] Failed to execute {emqx_web_hook,on_client_connect,[{undefined}]}: {exit,{timeout,{gen_server,call,[<0.29082.0>,{post,{"/api/web-hook/msg/webHook/",[{<<"content-type">>,<<"application/"...>>},{"content-type","application/json"}],<<"{\"username\":\"admin\","...>>},5000},6000]}},[{gen_server,call,3,[{file,"gen_server.erl"},{line,246}]},{ehttpc,request,5,[{file,"ehttpc.erl"},{line,69}]},{emqx_web_hook,send_http_request,2,[{file,"emqx_web_hook.erl"},{line,329}]},{emqx_hooks,safe_execute,2,[{file,"emqx_hooks.erl"},{line,191}]},{emqx_hooks,do_run_fold,3,[{file,"emqx_hooks.erl"},{line,170}]},{emqx_channel,run_conn_hooks,2,[{file,"emqx_channel.erl"},{line,1667}]},{emqx_misc,pipeline,3,[{file,"emqx_misc.erl"},{line,138}]},{emqx_channel,handle_in,2,[{file,"emqx_channel.erl"},{line,279}]},{emqx_connection,with_channel,3,[{file,[...]},{line,...}]},{emqx_connection,process_msg,2,[{file,...},{...}]},{emqx_connection,process_msg,2,[{...}|...]},{emqx_connection,handle_recv,3,[...]},{proc_lib,wake_up,3,...}]}
2021-06-06T16:01:24.627922+08:00 [error] sss0@103.100.65.248:42231 [Hooks] Failed to execute {emqx_web_hook,on_client_connected,[{undefined}]}: {exit,{timeout,{gen_server,call,[<0.29082.0>,{post,{"/api/web-hook/msg/webHook/",[{<<"content-type">>,<<"application/"...>>},{"content-type","application/json"}],<<"{\"username\":\"admin\","...>>},5000},6000]}},[{gen_server,call,3,[{file,"gen_server.erl"},{line,246}]},{ehttpc,request,5,[{file,"ehttpc.erl"},{line,69}]},{emqx_web_hook,send_http_request,2,[{file,"emqx_web_hook.erl"},{line,329}]},{emqx_hooks,safe_execute,2,[{file,"emqx_hooks.erl"},{line,191}]},{emqx_hooks,do_run,2,[{file,"emqx_hooks.erl"},{line,157}]},{emqx_channel,ensure_connected,1,[{file,"emqx_channel.erl"},{line,1664}]},{emqx_channel,handle_in,2,[{file,"emqx_channel.erl"},{line,294}]},{emqx_connection,with_channel,3,[{file,"emqx_connection.erl"},{line,658}]},{emqx_connection,process_msg,2,[{file,[...]},{line,...}]},{emqx_connection,process_msg,2,[{file,...},{...}]},{emqx_connection,handle_recv,3,[{...}|...]},{proc_lib,wake_up,3,[...]}]}
2021-06-06T16:01:28.066915+08:00 [error] sss0@103.100.65.248:42233 [Hooks] Failed to execute {emqx_web_hook,on_client_connected,[{undefined}]}: {exit,{timeout,{gen_server,call,[<0.29082.0>,{post,{"/api/web-hook/msg/webHook/",[{<<"content-type">>,<<"application/"...>>},{"content-type","application/json"}],<<"{\"username\":\"admin\","...>>},5000},6000]}},[{gen_server,call,3,[{file,"gen_server.erl"},{line,246}]},{ehttpc,request,5,[{file,"ehttpc.erl"},{line,69}]},{emqx_web_hook,send_http_request,2,[{file,"emqx_web_hook.erl"},{line,329}]},{emqx_hooks,safe_execute,2,[{file,"emqx_hooks.erl"},{line,191}]},{emqx_hooks,do_run,2,[{file,"emqx_hooks.erl"},{line,157}]},{emqx_channel,ensure_connected,1,[{file,"emqx_channel.erl"},{line,1664}]},{emqx_channel,handle_in,2,[{file,"emqx_channel.erl"},{line,294}]},{emqx_connection,with_channel,3,[{file,"emqx_connection.erl"},{line,658}]},{emqx_connection,process_msg,2,[{file,[...]},{line,...}]},{emqx_connection,process_msg,2,[{file,...},{...}]},{emqx_connection,handle_recv,3,[{...}|...]},{proc_lib,wake_up,3,[...]}]}
2021-06-06T16:01:30.628895+08:00 [error] sss0@103.100.65.248:42231 [Hooks] Failed to execute {emqx_web_hook,on_client_connack,[{undefined}]}: {exit,{timeout,{gen_server,call,[<0.29082.0>,{post,{"/api/web-hook/msg/webHook/",[{<<"content-type">>,<<"application/"...>>},{"content-type","application/json"}],<<"{\"username\":\"admin\","...>>},5000},6000]}},[{gen_server,call,3,[{file,"gen_server.erl"},{line,246}]},{ehttpc,request,5,[{file,"ehttpc.erl"},{line,69}]},{emqx_web_hook,send_http_request,2,[{file,"emqx_web_hook.erl"},{line,329}]},{emqx_hooks,safe_execute,2,[{file,"emqx_hooks.erl"},{line,191}]},{emqx_hooks,do_run_fold,3,[{file,"emqx_hooks.erl"},{line,170}]},{emqx_channel,handle_out,3,[{file,"emqx_channel.erl"},{line,1667}]},{emqx_connection,with_channel,3,[{file,"emqx_connection.erl"},{line,658}]},{emqx_connection,process_msg,2,[{file,"emqx_connection.erl"},{line,363}]},{emqx_connection,process_msg,2,[{file,[...]},{line,...}]},{emqx_connection,handle_recv,3,[{file,...},{...}]},{proc_lib,wake_up,3,[{...}|...]}]}
2021-06-06T16:01:36.629896+08:00 [error] sss0@103.100.65.248:42231 [Hooks] Failed to execute {emqx_web_hook,on_client_disconnected,[{undefined}]}: {exit,{timeout,{gen_server,call,[<0.29082.0>,{post,{"/api/web-hook/msg/webHook/",[{<<"content-type">>,<<"application/"...>>},{"content-type","application/json"}],<<"{\"username\":\"admin\","...>>},5000},6000]}},[{gen_server,call,3,[{file,"gen_server.erl"},{line,246}]},{ehttpc,request,5,[{file,"ehttpc.erl"},{line,69}]},{emqx_web_hook,send_http_request,2,[{file,"emqx_web_hook.erl"},{line,329}]},{emqx_hooks,safe_execute,2,[{file,"emqx_hooks.erl"},{line,191}]},{emqx_hooks,do_run,2,[{file,"emqx_hooks.erl"},{line,157}]},{emqx_channel,ensure_disconnected,2,[{file,"emqx_channel.erl"},{line,1664}]},{emqx_channel,handle_info,2,[{file,"emqx_channel.erl"},{line,974}]},{emqx_connection,with_channel,3,[{file,"emqx_connection.erl"},{line,658}]},{emqx_connection,process_msg,2,[{file,[...]},{line,...}]},{emqx_connection,handle_recv,3,[{file,...},{...}]},{proc_lib,wake_up,3,[{...}|...]}]}
2021-06-06T16:01:40.708869+08:00 [error] sss0@103.100.65.248:42231 [WebHook] HTTP request error: {shutdown,econnrefused}
2021-06-06T16:01:45.712052+08:00 [error] sss0@103.100.65.248:42233 [WebHook] HTTP request error: timeout
2021-06-06T16:01:50.713803+08:00 [error] sss0@103.100.65.248:42233 [WebHook] HTTP request error: timeout
2021-06-06T16:01:51.756874+08:00 [error] sss0@103.100.65.248:42233 [WebHook] HTTP request error: {shutdown,econnrefused}

下面是paho接连报的错误。

已断开连接 (32109) - java.io.IOException: Connection is lost.
	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:197)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Connection is lost.
	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:172)
	... 1 more
Exception in thread "main" 已断开连接 (32109) - java.io.IOException: Connection is lost.
	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:197)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Connection is lost.
	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:172)
	... 1 more

只要关闭了webhook连接就能正常,并且4.1.0的版本也正常。
webhook接口为:

应该是emqx访问不到你的java服务接口,试试在emqx的服务器上能不能访问http://msg-dev.lianwuzizai.com/api/web-hook/msg/webHook/ 地址 把注释的