我已经设置了 openfire 服务器,我的 android 客户端可以很好地使用它,除了我无法发布头像,问题是服务器只是忽略了发布头像 iq 数据包,没有错误,日志文件中没有任何内容。我正在使用标准的 XMPP pep avatar stanza,请支持
谢谢大家的回复,我发现问题出在 openfire server 3.10,它不能很好地解析标准 XEP 0084 节,事实上我发现日志和服务器崩溃了,所以我将 IQ 修改为,例如这应该是标准发布头像的智商
<iq type='set' from='juliet@capulet.lit/chamber' id='publish1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='urn:xmpp:avatar:data'>
<item id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f'>
<data xmlns='urn:xmpp:avatar:data'>
qANQR1DBwU4DX7jmYZnncm...
</data>
</item>
</publish>
</pubsub>
</iq>
但是正如您所看到的,标准 IQ 中没有“to”地址,openfire 服务器会在 DB 中创建 pubsub 节点并崩溃,并且不会回复要求用户现在发布元数据的结果,所以我必须做的是发送此数据包,然后是标准元数据数据包,然后再次发送带有“to”地址的元数据数据包,该地址将由服务器回复,结果元数据通知成功作为标准元数据首次发送到服务器,
<iq type='set' from='juliet@capulet.lit/chamber' id='publish2'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='urn:xmpp:avatar:metadata'>
<item id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f'>
<metadata xmlns='urn:xmpp:avatar:metadata'>
<info bytes='12345'
id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f'
height='64'
type='image/png'
width='64'/>
</metadata>
</item>
</publish>
</pubsub>
</iq>
然后再次像这样添加“到”地址
<iq type='set' from='juliet@capulet.lit/chamber' to="mydomain.com" id='publish2'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='urn:xmpp:avatar:metadata'>
<item id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f'>
<metadata xmlns='urn:xmpp:avatar:metadata'>
<info bytes='12345'
id='111f4b3c50d7b0df729d299bc6f8e9ef9066971f'
height='64'
type='image/png'
width='64'/>
</metadata>
</item>
</publish>
</pubsub>
</iq>
以上述方式头像发布正在工作,我也成功向其他用户发出通知
这是服务器崩溃日志以防万一
2016.03.02 10:41:02 ERROR [socket_c2s-thread-3]: org.jivesoftware.openfire.handler.IQHandler - Internal server error
java.lang.NullPointerException
at org.jivesoftware.openfire.pubsub.PubSubEngine.createNodeHelper(PubSubEngine.java:1165)
at org.jivesoftware.openfire.pubsub.PubSubEngine.publishItemsToNode(PubSubEngine.java:340)
at org.jivesoftware.openfire.pubsub.PubSubEngine.process(PubSubEngine.java:98)
at org.jivesoftware.openfire.pep.PEPServiceManager.process(PEPServiceManager.java:215)
at org.jivesoftware.openfire.pep.IQPEPHandler.handleIQ(IQPEPHandler.java:423)
at org.jivesoftware.openfire.handler.IQHandler.process(IQHandler.java:66)
at org.jivesoftware.openfire.IQRouter.handle(IQRouter.java:372)
at org.jivesoftware.openfire.IQRouter.route(IQRouter.java:115)
at org.jivesoftware.openfire.spi.PacketRouterImpl.route(PacketRouterImpl.java:78)
at org.jivesoftware.openfire.net.StanzaHandler.processIQ(StanzaHandler.java:342)
at org.jivesoftware.openfire.net.ClientStanzaHandler.processIQ(ClientStanzaHandler.java:99)
at org.jivesoftware.openfire.net.StanzaHandler.process(StanzaHandler.java:307)
at org.jivesoftware.openfire.net.StanzaHandler.process(StanzaHandler.java:199)
at org.jivesoftware.openfire.nio.ConnectionHandler.messageReceived(ConnectionHandler.java:181)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:690)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:417)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:47)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:765)
at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:109)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:417)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:47)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:765)
at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:407)
at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:236)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:417)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:47)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:765)
at org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:74)
at org.apache.mina.core.session.IoEvent.run(IoEvent.java:63)
at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTask(OrderedThreadPoolExecutor.java:769)
at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTasks(OrderedThreadPoolExecutor.java:761)
at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:703)
at java.lang.Thread.run(Unknown Source)