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

2024-04-23 15:56:39 发布

您现在位置:Python中文网/ 问答频道 /正文

好吧,这不是问题。我看到的所有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,否则某些服务器将不喜欢您,您将拔出所有头发并哭泣。在


Tags: tofromcommessagetypetwistedbodyjid
2条回答

根据我的实验,它不是self.parent.authenticator.jid.full(),而是self.parent.jid.full()。代码段如下

        reply = toResponse(msg, msg.getAttribute('type'))
        reply.addElement('body', content=unicode(msg.body))
        reply["from"] = self.parent.jid.full()
        self.send(reply)

在这种特殊情况下,对非问题的更好答案是根本不应该设置from地址。每一个服务器都会很乐意为你填写空白,从而省去了你的客户机JID。在

相关问题 更多 >