最新消息:VPS服务器又从fzhost.net换回Linode了,主题仍用朋友推荐的大前端D8

【已解决】尝试用XMPP去实现消息群发

XMPP crifan 214浏览 0评论

折腾:

[已解决]Swift中实现XMPP的讨论组群聊功能

期间,继续去尝试用XMPP去实现消息群发。

JEP-0XXX: Simplified Multi-User Chat

xmpp – Can’t send a group message – Error 400 – Modify – BadRequest – Stack Overflow

error code=’400′ type=’modify’ jid-malformed… can’t see what I am doing wrong… | ejabberd

后来发送消息,出错:

<message xmlns="jabber:client" from="group-c7b68ce4-bbe1-430d-b736-dd7eec6c4413@conference.jiandao.im/user-1f4857d8-5ea8-434e-8e7c-3f8d20f1f2cf" to="user-1f4857d8-5ea8-434e-8e7c-3f8d20f1f2cf@jiandao.im/9ae7ae89" type="error"><body>To all</body><error code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></message>

搜:

XMPP 400 type modify bad-request

c# – XMPP Registration is generating 400 bad request error – Stack Overflow

Sending a Message to All Occupants

xmpp – Can’t send a group message – Error 400 – Modify – BadRequest – Stack Overflow

好像是:

由于参考了进入room时发送的Presence的格式,而给group后面加了userID:

group-c7b68ce4-bbe1-430d-b736-dd7eec6c4413@conference.jiandao.im/user-1f4857d8-5ea8-434e-8e7c-3f8d20f1f2cf

但是这种格式,相当于:

当前用户,给group room内的,对应某个单个用户去发消息了,所以出现官网:

Example 48. Occupant Attempts to Send a Message of Type "Groupchat" to a Particular Occupant

If the sender attempts to send a private message of type "groupchat" to a particular occupant, the service MUST refuse to deliver the message (since the recipient’s client would expect in-room messages to be of type "groupchat") and return a <bad-request/> error to the sender:

Example 48. Occupant Attempts to Send a Message of Type "Groupchat" to a Particular Occupant

<message
   
from=‘wiccarocks@shakespeare.lit/laptop’
   
id=‘bx71f29k’
   
to=‘coven@chat.shakespeare.lit/firstwitch’
   
type=‘groupchat’>
 
<body>I’ll give thee a wind.</body></message><message
   
from=‘coven@chat.shakespeare.lit/firstwitch’
   
id=‘bx71f29k’
   
to=‘wiccarocks@shakespeare.lit/laptop’
   
type=‘error’>
 
<body>I’ll give thee a wind.</body>
 
<error by=‘coven@chat.shakespeare.lit’ type=‘modify’>
   
<bad-request xmlns=‘urn:ietf:params:xml:ns:xmpp-stanzas’/>
 
</error></message>
   

中说的400 bad-request错误

所以:

应该是,group后面不能加userId

结果发送:

<message from="user-1f4857d8-5ea8-434e-8e7c-3f8d20f1f2cf@jiandao.im" to="group-c7b68ce4-bbe1-430d-b736-dd7eec6c4413@conference.jiandao.im" type="groupchat"><body>To all</body></message>

虽然程序收到了:

<message xmlns="jabber:client" from="group-c7b68ce4-bbe1-430d-b736-dd7eec6c4413@conference.jiandao.im/user-1f4857d8-5ea8-434e-8e7c-3f8d20f1f2cf" to="user-1f4857d8-5ea8-434e-8e7c-3f8d20f1f2cf@jiandao.im/101f462f" type="groupchat"><body>To all</body></message>

但是别的客户端中,却没有收到刚发的这个消息

XMPP groupchat client not received

XMPP group chat client not received

#15033 (No received message notification in XMPP group chat) – Pidgin

后来找到原因了:

【总结】

原来是由于测试数据中的不同team下的group的名字一样,

而实际上是不同的group(room)导致我客户端和代码中,虽然都是同样的讨论组名字,但是实际上是不同的讨论组,导致消息互相收不到

-》确保同处于一个group==讨论组==room,则可以正常收到消息了。

转载请注明:在路上 » 【已解决】尝试用XMPP去实现消息群发

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
17 queries in 0.219 seconds, using 9.89MB memory