处理其他主机 [英] Handle see-other-host in smack

查看:173
本文介绍了处理其他主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用smack来连接到Microsoft的Xmpp Msn api.去年四月,他们对实现进行了更改,从而迫使客户端实现了"see-other-host" xmpp规范.当我尝试连接到"xmpp.messenger.live.com"时,我得到了

I'm trying to use smack in order to connect to Microsoft's Xmpp Msn api. Last april they made a change in their implementation which forces clients to implement the "see-other-host" xmpp specification. When I try to connect to "xmpp.messenger.live.com" I get

stream:error(请参阅其他主机) 在org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:260) 在org.jivesoftware.smack.PacketReader.access $ 000(PacketReader.java:43) 在org.jivesoftware.smack.PacketReader $ 1.run(PacketReader.java:70)

stream:error (see-other-host) at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:260) at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43) at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)

我正在调试,我可以看到原始接收到的数据包

I'm debugging and I can see the raw received packets

    <stream:stream from="messenger.live.com" version="1.0" id="59784" xmlns="jabber:client"     xmlns:stream="http://etherx.jabber.org/streams">
<stream:features xmlns:stream="http://etherx.jabber.org/streams"><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"><required /></starttls></stream:features>
<proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls" />
<stream:stream from="messenger.live.com" version="1.0" id="59785" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams">
<stream:error xmlns:stream="http://etherx.jabber.org/streams"><see-other-host xmlns="urn:ietf:params:xml:ns:xmpp-streams">BY2MSG3020517.gateway.edge.messenge r.live.com</see-other-host></stream:error>

但是我无法找到一种方法来拦截和处理该重定向. 有人这样做吗?任何帮助,将不胜感激.谢谢.

But I'm unable to find a way in order to intercept and handle that redirect. Has anybody done this? Any help would be appreciated. Thanks.

顺便说一句,我已经在smack论坛上发布了此帖子,但没有得到答复,希望这不会被视为交叉发布.

BTW I've already post this on smack forums but got no reply, hope this is isn't considered cross-posting.

推荐答案

此背景可能有助于解决问题

This background may help in fixing the problem

see-other-host流错误将客户端重定向到另一台服务器.就Messenger而言,其目的是允许客户端在其当前服务器停止服务时干净地切换到另一台服务器,或为了负载平衡目的而连接到另一台服务器.

The see-other-host stream error redirects a client to another server. In the case of Messenger, it's intended to allow clients to cleanly switch to another server should their current server go out of service, or to connect to another server for load-balancing purposes.

基于使用SAMCK的示例Java代码,存在两个问题:

Based on Sample Java Codes that uses SAMCK there are two problems:

  1. 注册的连接侦听器未收到有关异常的通知
  2. 无法从XMPPException访问流错误的文本元素

内部处理重定向是最友好的解决方案,但是将新服务器通知客户端将至少允许客户端建立新连接而无需用户干预.

Handling the redirection internally would be the friendliest solution, but notifying the client of the new server would at least allow clients to make a new connection without user intervention.

这篇关于处理其他主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆