最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

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

XMPP crifan 3902浏览 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="[email protected]/user-1f4857d8-5ea8-434e-8e7c-3f8d20f1f2cf" to="[email protected]/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:

[email protected]/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=
[email protected]/laptop’
   
id=‘bx71f29k’
   
to=[email protected]/firstwitch’
   
type=‘groupchat’>
 
<body>I’ll give thee a wind.</body></message><message
   
from=[email protected]/firstwitch’
   
id=‘bx71f29k’
   
to=[email protected]/laptop’
   
type=‘error’>
 
<body>I’ll give thee a wind.</body>
 
<error by=[email protected] type=‘modify’>
   
<bad-request xmlns=‘urn:ietf:params:xml:ns:xmpp-stanzas’/>
 
</error></message>
   

中说的400 bad-request错误

所以:

应该是,group后面不能加userId

结果发送:

<message from="[email protected]" to="[email protected]" type="groupchat"><body>To all</body></message>

虽然程序收到了:

<message xmlns="jabber:client" from="[email protected]/user-1f4857d8-5ea8-434e-8e7c-3f8d20f1f2cf" to="[email protected]/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,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.186 seconds, using 22.26MB memory