xmpppy 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"))