XMPPPY 无法连接到服务器
Posted
技术标签:
【中文标题】XMPPPY 无法连接到服务器【英文标题】:XMPPPY unable to connect to the server 【发布时间】:2015-12-12 08:48:28 【问题描述】:我正在使用 xmpppy python 库连接 XMPP 服务器(ejabberd2),但无法连接,实际上并不清楚如何连接、验证和向服务器发送消息。
请帮我让它工作
如果可能,请提供一些使用 XMPPPY 的代码 sn-p。
【问题讨论】:
【参考方案1】:我在朋友的帮助下找到了解决办法
它需要更改 XMPP ejabberd 服务器配置。 将 hosts, ["localhost"] 行更改为 hosts, ["localhost", "server-domain", "server-ip-address"]在 ejabberd.cfg 文件中。
重启服务器,并在新主机下使用服务器域或服务器ip创建另一个用户。
代码 sn-p:
import xmpp
ipaddress='<server-ip>'
user='<new-user>' #without @<server-ip>
passwd='<password>'
c = xmpp.Client(ipaddress)
c.connect((ipaddress,5222), secure=0)
c.auth(user,passwd,sasl=1)
c.sendInitPresence()
c.isConnected()
c.send(xmpp.protocol.Message('<jid of receiver user with @<domain> >',"hello world"))
【讨论】:
以上是关于XMPPPY 无法连接到服务器的主要内容,如果未能解决你的问题,请参考以下文章
无法使用php连接错误连接到mysql:无法连接到'localhost'(10061)上的MySQL服务器[重复]