为什么ejabberd在收到消息后不向客户端发送消息



我正在使用REST API/API/send_message从android设备向ejabberd服务器发送消息,并在服务器端成功接收到消息,但在接收到ejabbered服务器未发送到客户端的消息后。我从客户那里发送了一条消息,内容如下:192.168.1.24:5443/api/send_message?"type"= "normal",&"from"= "admin@faiqkhan-Virtualbox",&"to"= "faiq@faiqkhan-Virtualbox",&"subject"= "Restart",&"body"="In 5 minutes"我还将on_user_send_packet lister登录到ejabberd上,并打印数据包的数据,该数据包显示的数据与我从客户端发送的数据包相同。我正在使用android中的stack库。我收到消息的服务器端模块部分:

on_user_send_packet({#message{from = From, body = Body, 
subject = Subject} = Packet, C2SState}) ->
?INFO_MSG("mod_stanza_ack message packet: ~p~n", [Packet]),
?INFO_MSG("mod_stanza_ack message subject: ~p~n", [Subject]),
?INFO_MSG("mod_stanza_ack message body ignored: ~p~n", [Body])
end,
{Packet, C2SState}.

服务器日志:

API call send_message [{<<"type">>,<<"normal">>},{<<"from">>,<<"67456efc-be57-4cbd-a176-527de2dce19d@faiqkhan-virtualbox">>},{<<"to">>,<<"e5d6d83c-ea77-4d10-aaac-4e0e38899ac2@faiqkhan-virtualbox">>},{<<"subject">>,<<"Restart">>},{<<"body">>,<<"In 5 minutes">>}] from ::ffff:192.168.1.46:51597
13:43:14.298 [info] mod_stanza_ack message packet: {message,<<"4325851467592961166">>,normal,<<>>,{jid,<<"67456efc-be57-4cbd-a176-527de2dce19d">>,<<"faiqkhan-virtualbox">>,<<>>,<<"67456efc-be57-4cbd-a176-527de2dce19d">>,<<"faiqkhan-virtualbox">>,<<>>},{jid,<<"e5d6d83c-ea77-4d10-aaac-4e0e38899ac2">>,<<"faiqkhan-virtualbox">>,<<>>,<<"e5d6d83c-ea77-4d10-aaac-4e0e38899ac2">>,<<"faiqkhan-virtualbox">>,<<>>},[{text,<<>>,<<"Restart">>}],[{text,<<>>,<<"In 5 minutes">>}],undefined,[],#{}}
13:43:14.298 [info] mod_stanza_ack message subject: [{text,<<>>,<<"Restart">>}]
13:43:14.298 [info] mod_stanza_ack message body ignored: [{text,<<>>,<<"In 5 minutes">>}]

尝试使用stack库的回调在客户端接收消息

public void newIncomingMessage(EntityBareJid from, Message message, Chat chat)

我是不是错过了客户端的一些听众?

对我来说是正确的。我注册帐户adminfaiq,在Tkabber客户端登录faiq帐户,然后发送API查询:

ejabberdctl send_message normal admin@localhost faiq@localhost Restart In5minutes

客户端完美地接收到消息:

<message to='faiq@localhost'
from='admin@localhost'
id='18338888910541408674'>
<archived by='faiq@localhost'
id='1599730686404819'
xmlns='urn:xmpp:mam:tmp'/>
<stanza-id by='faiq@localhost'
id='1599730686404819'
xmlns='urn:xmpp:sid:0'/>
<body>In5minutes</body>
<subject>Restart</subject>
</message>

您可以使用著名的Jabber桌面客户端(如Gajim或Psi(登录,以检查您的API调用是否正常工作。这样你就会知道问题是否在你的客户身上,或者在哪里。。。

相关内容

  • 没有找到相关文章

最新更新