简体   繁体   English

python不连接到本地XMPP服务器

[英]python does not connect to local XMPP server

i'm trying to connect my local XMPP server by the code coming below 我正在尝试通过下面的代码连接我的本地XMPP服务器

import xmpp
client = xmpp.Client('localhost',debug=[])
client.connect(server=('localhost',5222))

but i always get this message : 但我总是得到这样的信息:

An error occurred while looking up _xmpp-client._tcp.localhost 查找_xmpp-client._tcp.localhost时发生错误

i've checked that the port 5222 is already opened(by using telnet). 我已检查端口5222是否已打开(使用telnet)。 (i have to mention that the firewall on the localhost is off) now what should i add to this code to make it work ? (我必须提到本地主机上的防火墙已关闭)现在应该添加到此代码中以使其工作?

This message (a warning, not an error as pointed out in xinox's answer) is indicating that a DNS SRV record lookup failed. 此消息(警告,而不是xinox的答案中指出的错误)表示DNS SRV记录查找失败。 DNS SRV records are used to find services that are associated with a certain domain (eg. localhost in this case, so not really a domain at all which is why the lookup is failing), but which delegate their responsibility to a server living somewhere else. DNS SRV记录用于查找与某个域相关联的服务(例如,在这种情况下为localhost ,因此根本不是一个域,这就是查找失败的原因),但是将其责任委托给居住在其他地方的服务器。

For instance, if I have a server at example.net , making my Jabber ID (JID): user@example.net , but my XMPP server lived at chat.example.net I could construct an SRV record on example.net to point to chat.example.net . 例如,如果我在example.net有一个服务器,制作我的Jabber ID(JID): user@example.net ,但我的XMPP服务器住在chat.example.net我可以在example.net上构建一个SRV记录来指向到chat.example.net There are other ways to delegate responsibility, but this is the preferred one. 还有其他方式来委派责任,但这是首选方法。 XMPPs use of SRV records is defined in RFC 6120 §3.2.1 . SRMP记录的XMPP使用在RFC6120§3.2.1中定义。

To actually get rid of this error you can use the use_srv kwarg, making your initial example: 要真正摆脱这个错误,你可以使用use_srv kwarg,制作你的初始例子:

import xmpp
client = xmpp.Client('localhost',debug=[])
client.connect(server=('localhost',5222), use_srv=False)

use this. 用这个。

client = xmpp.Client('127.0.0.1',debug=[])
client.connect(server=('127.0.0.1',5222))

or your IP 192.XXX 或者您的IP 192.XXX

i figured this out , just remember that this is a warning not just an error . 我想出了这一点,只记得这是一个警告而不仅仅是一个错误。 the python connected to openfire XMPP server correctly and it works fine . python正确连接到openfire XMPP服务器,它工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM