我刚安装了ejabbered和sleekxmpp。我正在尝试运行如http://sleekxmpp.com/#here-s-your-first-sleekxmpp-bot所述的示例程序。使用ejabbered admin我创建了一个示例用户。
Web Admin->Virtual Hosts->selected test@test.com->Users->Added new user name password
所以修改后的代码是:
if __name__ == '__main__':
# Ideally use optparse or argparse to get JID,
# password, and log level.
logging.basicConfig(level=logging.DEBUG,
format='%(levelname)-8s %(message)s')
xmpp = EchoBot('test_user@test.com', 'password')
xmpp.connect()
xmpp.process(block=True)
输出:
DEBUG Loaded Plugin: RFC 6120: Stream Feature: STARTTLS
DEBUG Loaded Plugin: RFC 6120: Stream Feature: Resource Binding
DEBUG Loaded Plugin: RFC 3920: Stream Feature: Start Session
DEBUG Loaded Plugin: RFC 6121: Stream Feature: Roster Versioning
DEBUG Loaded Plugin: RFC 6121: Stream Feature: Subscription Pre-Approval
DEBUG Loaded Plugin: RFC 6120: Stream Feature: SASL
WARNING DNS: dnspython not found. Can not use SRV lookup.
DEBUG DNS: Querying test@test.com for AAAA records.
DEBUG DNS: Error retreiving AAAA address info for test@test.com.
DEBUG DNS: Querying test@test.com for A records.
DEBUG Connecting to xx.xx.xxx.xxx:5222
ERROR Could not connect to xx.xx.xxx.xxx:5222. Socket Error #111: Connection refused
DEBUG No remaining DNS records to try.
DEBUG Waiting 2.27851082363 seconds before connecting.
WARNING DNS: dnspython not found. Can not use SRV lookup.
DEBUG DNS: Querying test@test.com for AAAA records.
DEBUG DNS: Error retreiving AAAA address info for test@test.com.
DEBUG DNS: Querying test@test.com for A records.
DEBUG Connecting to xx.xx.xxx.xxx:5222
ERROR Could not connect to xx.xx.xxx.xxx:5222. Socket Error #111: Connection refused
DEBUG Waiting 1.85516992239 seconds before connecting.
DEBUG No remaining DNS records to try.
DEBUG Waiting 3.72981095414 seconds before connecting.
DEBUG Starting HANDLER THREAD
DEBUG Loading event runner
DEBUG Stopped event runner thread. -1 threads remain.
DEBUG Stopped send thread. -1 threads remain.
DEBUG Quitting Scheduler thread
DEBUG Stopped scheduler thread. 0 threads remain.
$ ^C
请让我知道如何纠正这个问题?
===更新====
我正在使用Wi-Fi n / w所以当我给ifconfig命令时,我得到以下输出:
$ ifconfig
eth0 Link encap:Ethernet HWaddr 30:f9:ed:cd:64:51
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:4043 errors:0 dropped:0 overruns:0 frame:0
TX packets:4043 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:606641 (606.6 KB) TX bytes:606641 (606.6 KB)
wlan0 Link encap:Ethernet HWaddr a4:17:31:de:e4:d9
inet addr:10.0.0.2 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::a617:31ff:fede:e4d9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:46103 errors:0 dropped:0 overruns:0 frame:0
TX packets:44757 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:48717711 (48.7 MB) TX bytes:6499289 (6.4 MB)
10.0.0.2是我的路由器地址,它与程序调试日志中显示的xx.xx.xx.xxx不同 - 它是否与此IP配置有关 - 如果是这样,我在哪里修改什么值?
==更新===
调试级别日志向我显示以下信息:[ test@test.com认证失败]:
进一步的Jabber客户端使用ignore选项指出与证书相关的错误。
=INFO REPORT==== 2013-08-26 18:12:49 ===
I(<0.37.0>:ejabberd_app:72) : ejabberd 2.1.10 is started in the node 'ejabberd@test.com'
=INFO REPORT==== 2013-08-26 18:14:08 ===
I(<0.542.0>:ejabberd_listener:281) : (#Port<0.1832>) Accepted connection {{127,0,0,1},39872} -> {{127,0,1,1},5222}
=INFO REPORT==== 2013-08-26 18:14:08 ===
D(<0.545.0>:ejabberd_receiver:320) : Received XML on stream = "<?xml version='1.0'?><stream:stream xmlns=\"jabber:client\" to=\"test.com\" version=\"1.0\" xmlns:stream=\"http://etherx.jabber.org/streams\" xml:lang=\"en\" >"
=INFO REPORT==== 2013-08-26 18:14:08 ===
D(<0.546.0>:ejabberd_c2s:1553) : Send XML on stream = [60,63,120,109,108,32,
118,101,114,115,105,
111,110,61,39,49,46,48,
39,63,62,60,115,116,
114,101,97,109,58,115,
116,114,101,97,109,32,
120,109,108,110,115,61,
39,106,97,98,98,101,
114,58,99,108,105,101,
110,116,39,32,120,109,
108,110,115,58,115,116,
114,101,97,109,61,39,
104,116,116,112,58,47,
47,101,116,104,101,114,
120,46,106,97,98,98,
101,114,46,111,114,103,
47,115,116,114,101,97,
109,115,39,32,105,100,
61,39,"4262884447",39,
32,102,114,111,109,61,
39,
"test.com",
39,
[" version='","1.0",
"'"],
[" xml:lang='","en",
"'"],
62]
=INFO REPORT==== 2013-08-26 18:14:08 ===
D(<0.546.0>:ejabberd_c2s:1553) : Send XML on stream = <<"<stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>SCRAM-SHA-1</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='TQ2JFyRoSa70h2G1bpgjzuXb2sU='/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>">>
=INFO REPORT==== 2013-08-26 18:14:08 ===
D(<0.545.0>:ejabberd_receiver:320) : Received XML on stream = "<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>"
=INFO REPORT==== 2013-08-26 18:14:08 ===
D(<0.545.0>:shaper:61) : State: {maxrate,1000,0,1377521048483549}, Size=51
M=25.5, I=4.907
=INFO REPORT==== 2013-08-26 18:14:08 ===
D(<0.545.0>:ejabberd_receiver:320) : Received XML on stream = []
=INFO REPORT==== 2013-08-26 18:14:08 ===
D(<0.545.0>:shaper:61) : State: {maxrate,1000,983.8342528646939,
1377521048509468}, Size=0
M=0.0, I=-19.024
=INFO REPORT==== 2013-08-26 18:14:08 ===
D(<0.545.0>:ejabberd_receiver:320) : Received XML on stream = []
=INFO REPORT==== 2013-08-26 18:14:08 ===
D(<0.545.0>:shaper:61) : State: {maxrate,1000,491.91712643234695,
1377521048510450}, Size=0
M=0.0, I=93.656
=INFO REPORT==== 2013-08-26 18:14:08 ===
D(<0.545.0>:ejabberd_receiver:320) : Received XML on stream = []
=INFO REPORT==== 2013-08-26 18:14:08 ===
D(<0.545.0>:shaper:61) : State: {maxrate,1000,245.95856321617347,
1377521048604127}, Size=0
M=0.0, I=6.537
=INFO REPORT==== 2013-08-26 18:14:08 ===
D(<0.545.0>:ejabberd_receiver:320) : Received XML on stream = "<?xml version='1.0'?><stream:stream xmlns=\"jabber:client\" to=\"test.com\" version=\"1.0\" xmlns:stream=\"http://etherx.jabber.org/streams\" xml:lang=\"en\" >"
=INFO REPORT==== 2013-08-26 18:14:08 ===
D(<0.545.0>:shaper:61) : State: {maxrate,1000,122.97928160808674,
1377521048610682}, Size=161
M=85.7742263697187, I=1.123
=INFO REPORT==== 2013-08-26 18:14:08 ===
D(<0.546.0>:ejabberd_c2s:1553) : Send XML on stream = [60,63,120,109,108,32,
118,101,114,115,105,
111,110,61,39,49,46,48,
39,63,62,60,115,116,
114,101,97,109,58,115,
116,114,101,97,109,32,
120,109,108,110,115,61,
39,106,97,98,98,101,
114,58,99,108,105,101,
110,116,39,32,120,109,
108,110,115,58,115,116,
114,101,97,109,61,39,
104,116,116,112,58,47,
47,101,116,104,101,114,
120,46,106,97,98,98,
101,114,46,111,114,103,
47,115,116,114,101,97,
109,115,39,32,105,100,
61,39,"665429700",39,
32,102,114,111,109,61,
39,
"test.com",
39,
[" version='","1.0",
"'"],
[" xml:lang='","en",
"'"],
62]
=INFO REPORT==== 2013-08-26 18:14:08 ===
D(<0.546.0>:ejabberd_c2s:1553) : Send XML on stream = <<"<stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>SCRAM-SHA-1</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='TQ2JFyRoSa70h2G1bpgjzuXb2sU='/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>">>
=INFO REPORT==== 2013-08-26 18:14:23 ===
D(<0.545.0>:ejabberd_receiver:320) : Received XML on stream = "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"SCRAM-SHA-1\">biwsbj1zYXR5YSxyPTg2YWZmYTQxNzZjMmMxMzc1NDg1N2NmNGU1ZDcwNTAzNTBiMDU2YWQ4NTc4ZmMxNA==</auth>"
=INFO REPORT==== 2013-08-26 18:14:23 ===
D(<0.545.0>:shaper:61) : State: {maxrate,1000,0,1377521048612173}, Size=162
M=81.0, I=15096.97
**=INFO REPORT==== 2013-08-26 18:14:23 ===
I(<0.546.0>:ejabberd_c2s:649) : ({socket_state,tls,{tlssock,#Port<0.1832>,#Port<0.1860>},<0.545.0>}) Failed authentication for test@test.com**
=INFO REPORT==== 2013-08-26 18:14:23 ===
D(<0.546.0>:ejabberd_c2s:1553) : Send XML on stream = <<"<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized/></failure>">>
=INFO REPORT==== 2013-08-26 18:14:23 ===
D(<0.545.0>:ejabberd_receiver:320) : Received XML on stream = "<abort xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" />"
=INFO REPORT==== 2013-08-26 18:14:23 ===
D(<0.545.0>:shaper:61) : State: {maxrate,1000,5.365311472890604,
1377521063709153}, Size=50
M=25.067246793407225, I=1.775
^C