我遵循教程https://docs.ejabberd.im/admin/guide/mqtt/#enabling-ejabberd中的mqtt服务。
这是我的配置,与教程相同。我还打开了AWS安全组上的端口18838883。
hosts:
- "localhost"
listen:
-
port: 1883
module: mod_mqtt
backlog: 1000
-
port: 5280
module: ejabberd_http
request_handlers:
...
"/mqtt": mod_mqtt
-
port: 8883
module: mod_mqtt
backlog: 1000
tls: true
# adapt the path to your own certfile
certfiles:
- "/var/snap/ejabberd/tls/mqtt.pem"
modules:
...
mod_mqtt: {}
然而,ejabord未能启动,抛出以下错误:
2020-03-29 21:30:59.416 [error] <0.299.0> Supervisor ejabberd_listener had child
{1883,{0,0,0,0},tcp} started with ejabberd_listener:start({1883,{0,0,0,0},tcp},
mod_mqtt, [{backlog,1000}]) at undefined exit with reason {'EXIT',{undef,
[{mod_mqtt,socket_type,[],[]},{ejabberd_listener,start,3,[{file,
"src/ejabberd_listener.erl"},{line,86}]},{supervisor,do_start_child,2,[{file,
"supervisor.erl"},{line,358}]},{supervisor,start_children,3,[{file,
"supervisor.erl"},{line,341}]},{supervisor,init_children,2,[{file,
"supervisor.erl"},{line,307}]},{gen_server,init_it,6,[{file,"gen_server.erl"},
{line,328}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}}
in context start_error
和
2020-03-29 21:29:31.371 [error] <0.38.0>@ejabberd_config:validate_opts:1022
unknown option 'certfiles' will be likely ignored
{undef,〔{mod_mqtt,socket_type,〔〕,〔〕},
这意味着erlang找不到文件mod_mqtt.beam
。。。或者可能找到了该文件,但它不包括函数socket_type/0的定义。具有该功能的模块添加在ejabberd 19.02中:https://github.com/processone/ejabberd/commit/a3df791373c30ccc79a6082f4c910a378d726cdc
所以,也许你安装了一个旧版本,或者它安装错误,缺少那个模块。
未知选项"certfiles"可能会被忽略
选项certfiles
是在射精17.11中添加的,所以我不明白最近的射精者怎么会抱怨它是未知的:
https://github.com/processone/ejabberd/commit/35b7203e01aefbdfe4ea7804ebe20a8667466628