我正在尝试在ejabberd中创建一个简单的echo bot。我认为mod_echo工作正常,我相当肯定我有自己的版本在某一点工作(调试已经玩弄了我的头脑)。我收到下面的错误,但我无法弄清楚接下来要做什么来调试它。路由似乎有问题但不太确定原因。有什么提示吗?
2016-03-31 16:49:38.350 [debug] <0.448.0>@ejabberd_router:do_route:324 route
from {jid,<<"user1">>,<<"alchemy.local">>,<<"alchemy">>,<<"user1">>,<<"alchemy.local">>,<<"alchemy">>}
to {jid,<<>>,<<"echo.alchemy.local">>,<<>>,<<>>,<<"echo.alchemy.local">>,<<>>}
packet {xmlel,<<"message">>,[{<<"xml:lang">>,<<"en">>},{<<"to">>,<<"echo.alchemy.local">>},{<<"id">>,<<"aacca">>}],[{xmlcdata,<<"\n">>},{xmlel,<<"subject">>,[],[]},{xmlcdata,<<"\n">>},{xmlel,<<"body">>,[],[{xmlcdata,<<"testme">>}]},{xmlcdata,<<"\n">>},{xmlel,<<"nick">>,[{<<"xmlns">>,<<"http://jabber.org/protocol/nick">>}],[{xmlcdata,<<"user1">>}]},{xmlcdata,<<"\n">>}]}
2016-03-31 16:49:38.351 [error] <0.448.0>@ejabberd_router:route:77 {function_clause,[{mod_echobot,route,[{jid,<<"user1">>,<<"alchemy.local">>,<<"alchemy">>,<<"user1">>,<<"alchemy.local">>,<<"alchemy">>},{jid,<<>>,<<"echo.alchemy.local">>,<<>>,<<>>,<<"echo.alchemy.local">>,<<>>},{xmlel,<<"message">>,[{<<"xml:lang">>,<<"en">>},{<<"to">>,<<"echo.alchemy.local">>},{<<"id">>,<<"aacca">>}],[{xmlcdata,<<"\n">>},{xmlel,<<"subject">>,[],[]},{xmlcdata,<<"\n">>},{xmlel,<<"body">>,[],[{xmlcdata,<<"testme">>}]},{xmlcdata,<<"\n">>},{xmlel,<<"nick">>,[{<<"xmlns">>,<<"http://jabber.org/protocol/nick">>}],[{xmlcdata,<<"user1">>}]},{xmlcdata,<<"\n">>}]}],[{file,"mod_echobot.erl"},{line,86}]},{ejabberd_router,route,3,[{file,"src/ejabberd_router.erl"},{line,75}]},{ejabberd_c2s,check_privacy_route,5,[{file,"src/ejabberd_c2s.erl"},{line,2121}]},{ejabberd_c2s,session_established2,2,[{file,"src/ejabberd_c2s.erl"},{line,1288}]},{p1_fsm,handle_msg,10,[{file,"src/p1_fsm.erl"},{line,582}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,237}]}]}
when processing: {{jid,<<"user1">>,<<"alchemy.local">>,<<"alchemy">>,<<"user1">>,<<"alchemy.local">>,<<"alchemy">>},{jid,<<>>,<<"echo.alchemy.local">>,<<>>,<<>>,<<"echo.alchemy.local">>,<<>>},{xmlel,<<"message">>,[{<<"xml:lang">>,<<"en">>},{<<"to">>,<<"echo.alchemy.local">>},{<<"id">>,<<"aacca">>}],[{xmlcdata,<<"\n">>},{xmlel,<<"subject">>,[],[]},{xmlcdata,<<"\n">>},{xmlel,<<"body">>,[],[{xmlcdata,<<"testme">>}]},{xmlcdata,<<"\n">>},{xmlel,<<"nick">>,[{<<"xmlns">>,<<"http://jabber.org/protocol/nick">>}],[{xmlcdata,<<"user1">>}]},{xmlcdata,<<"\n">>}]}}
2016-03-31 16:50:16.356 [debug] <0.447.0>@ejabberd_receiver:process_data:282 Received XML on stream = <<"\n">>
答案 0 :(得分:0)
似乎在代码示例中(来自我在网上找到的旧样本)https://gist.github.com/stevenlivz/d666200595a23c42b2a662fef87bf281我需要使用&lt;&lt;&#34; message&#34;&gt;&gt;在实际匹配的子句中,而我使用的示例代码没有这样做,只使用&#34; message&#34;等等。另外,还值得注意的是xmlelement现在是xmlel,因此也需要更新子句。 E.g。
route(From, To, {xmlel, <<"message">>, _, _} = Packet) ->