Python XMPPPY无法连接到服务器

Python XMPPPY无法连接到服务器,python,xmpp,ejabberd,xmpppy,Python,Xmpp,Ejabberd,Xmpppy,我正在使用XMPPY python库连接XMPP服务器(ejabberd2),但无法连接,实际上不清楚如何连接、验证和向服务器发送消息 请帮我使它工作 如果可能,请使用XMPPPY提供一些代码片段 我在朋友的帮助下想出了解决办法 它需要更改XMPP ejabberd服务器配置中的。 将ejabberd.cfg文件中的{hosts,[“localhost”]}行更改为{hosts,[“localhost”,“server domain”,“server ip address”]} 重新启动服务器,

我正在使用XMPPY python库连接XMPP服务器(ejabberd2),但无法连接,实际上不清楚如何连接、验证和向服务器发送消息

请帮我使它工作

如果可能,请使用XMPPPY提供一些代码片段


我在朋友的帮助下想出了解决办法

它需要更改XMPP ejabberd服务器配置中的。 将ejabberd.cfg文件中的{hosts,[“localhost”]}行更改为{hosts,[“localhost”,“server domain”,“server ip address”]}

重新启动服务器,并在具有服务器域或服务器ip的新主机下创建另一个用户

代码片段:

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"))
导入xmpp
IP地址=“”
用户=“”#无@
passwd=''
c=xmpp.Client(ipaddress)
c、 连接((ipaddress,5222),安全=0)
c、 身份验证(用户,密码,sasl=1)
c、 sendInitPresence()
c、 断开连接()
c、 发送(xmpp.protocol.Message(“”,“hello world”))