为什么所有twisted/wokkel xmpp示例都忽略了xmpp协议中JID的正确用法?

use*_*116 1 python xmpp twisted google-talk

好的,这不是一个问题.我所看到的所有wokkel和twisted的例子都没有正确地观察JID中生成的资源.

使用wokkel/twisted构建的Google Talk客户端通常会中断,因为他们没有在响应中设置完整的JID,从而导致(非常隐藏的,低级别)错误,例如:

<message to="example@gmail.com" from="example2@synthasite.com/Example2C2F32A1" type="error"><body>echo: None</body><error code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">If set, the 'from' attribute must be set to the user's full JID.</text></error></message>

服务器发出的完整jid可以在self.parent.authenticator.jid.full()的协议处理程序中获得.

所以,在发送消息时,确保你在你的字段中使用完整的jid,或者某些服务器不喜欢你,你会拔掉所有的头发,然后哭.

小智 5

在这种特殊情况下,对非问题的更好答案是您不应该设置起始地址.每个服务器都会很乐意为您填写空白,从而使您无需了解客户端的JID.