好吧,这不是问题。我见过的所有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()获得
因此,在发送消息时,请确保在from字段中使用完整的jid,否则某些服务器会不喜欢您,您会拔出头发,哭出来。
发布于 2010-04-07 15:23:05
在这种情况下,非问题的更好答案是您根本不应该设置发件人地址。每台服务器都会很高兴地为您填补空白,使您不必再去计算客户端的JID。
发布于 2013-12-23 07:25:41
根据我的实验,它不是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)https://stackoverflow.com/questions/1957255
复制相似问题