2013-04-08 298 views
0

我搜索瞭如何在Python中創建Openfire帳戶,並發現以下answerxmpppy創建用戶帳戶

我試圖通過Joe Hildebrand給出與

python register.py [email protected] bar 

運行在運行的Openfire 3.8.1本機代碼來創建一個帳戶。

但是,我得到「錯誤!」信息。

有什麼我錯過了嗎?

編輯
刪除, debug[] 並再次嘗試後,我得到了以下信息:

Invalid debugflag given: always 
Invalid debugflag given: nodebuilder 
DEBUG: 
DEBUG: Debug created for /usr/local/lib/python2.7/dist-packages/xmpppy-0.5.0rc1-py2.7.egg/xmpp/client.py 
DEBUG: flags defined: always,nodebuilder 
DEBUG: socket  start Plugging <xmpp.transports.TCPsocket instance at 0x19991b8> into <xmpp.client.Client instance at 0x1988fc8> 
DEBUG: socket  warn An error occurred while looking up _xmpp-client._tcp.localhost 
DEBUG: socket  start Successfully connected to remote host ('localhost', 5222) 
DEBUG: dispatcher start Plugging <xmpp.dispatcher.Dispatcher instance at 0x199b2d8> into <xmpp.client.Client instance at 0x1988fc8> 
DEBUG: dispatcher info Registering namespace "unknown" 
DEBUG: dispatcher info Registering protocol "unknown" as <class 'xmpp.protocol.Protocol'>(unknown) 
DEBUG: dispatcher info Registering protocol "default" as <class 'xmpp.protocol.Protocol'>(unknown) 
DEBUG: dispatcher info Registering namespace "http://etherx.jabber.org/streams" 
DEBUG: dispatcher info Registering protocol "unknown" as <class 'xmpp.protocol.Protocol'>(http://etherx.jabber.org/streams) 
DEBUG: dispatcher info Registering protocol "default" as <class 'xmpp.protocol.Protocol'>(http://etherx.jabber.org/streams) 
DEBUG: dispatcher info Registering namespace "jabber:client" 
DEBUG: dispatcher info Registering protocol "unknown" as <class 'xmpp.protocol.Protocol'>(jabber:client) 
DEBUG: dispatcher info Registering protocol "default" as <class 'xmpp.protocol.Protocol'>(jabber:client) 
DEBUG: dispatcher info Registering protocol "iq" as <class 'xmpp.protocol.Iq'>(jabber:client) 
DEBUG: dispatcher info Registering protocol "presence" as <class 'xmpp.protocol.Presence'>(jabber:client) 
DEBUG: dispatcher info Registering protocol "message" as <class 'xmpp.protocol.Message'>(jabber:client) 
DEBUG: dispatcher info Registering handler <bound method Dispatcher.streamErrorHandler of <xmpp.dispatcher.Dispatcher instance at 0x199b2d8>> for "error" type-> ns->(http://etherx.jabber.org/streams) 
DEBUG: dispatcher warn Registering protocol "error" as <class 'xmpp.protocol.Protocol'>(http://etherx.jabber.org/streams) 
DEBUG: socket  sent <?xml version='1.0'?> 
    <stream:stream xmlns="jabber:client" to="localhost" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" > 
DEBUG: socket  got <?xml version='1.0' encoding='UTF-8'?> 
    <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="mymachine" id="1724a327" xml:lang="en" version="1.0"> 
DEBUG: socket  got <stream:features> 
    <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"> 
    </starttls> 
    <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"> 
    <mechanism>DIGEST-MD5</mechanism> 
    <mechanism>PLAIN</mechanism> 
    <mechanism>ANONYMOUS</mechanism> 
    <mechanism>CRAM-MD5</mechanism> 
    </mechanisms> 
    <compression xmlns="http://jabber.org/features/compress"> 
    <method>zlib</method> 
    </compression> 
    <auth xmlns="http://jabber.org/features/iq-auth"/> 
    <register xmlns="http://jabber.org/features/iq-register"/> 
    </stream:features> 
DEBUG: dispatcher warn Unknown stanza: features 
DEBUG: dispatcher ok Dispatching unknown stanza with type-> props->[u'urn:ietf:params:xml:ns:xmpp-tls', u'urn:ietf:params:xml:ns:xmpp-sasl', u'http://jabber.org/features/compress', u'http://jabber.org/features/iq-auth', u'http://jabber.org/features/iq-register'] id->None 
DEBUG: tls   start Plugging <xmpp.transports.TLS instance at 0x199b908> into <xmpp.client.Client instance at 0x1988fc8> 
DEBUG: tls   ok TLS supported by remote server. Requesting TLS start. 
DEBUG: dispatcher info Registering handler <bound method TLS.StartTLSHandler of <xmpp.transports.TLS instance at 0x199b908>> for "proceed" type-> ns->(urn:ietf:params:xml:ns:xmpp-tls) 
DEBUG: dispatcher warn Registering namespace "urn:ietf:params:xml:ns:xmpp-tls" 
DEBUG: dispatcher info Registering protocol "unknown" as <class 'xmpp.protocol.Protocol'>(urn:ietf:params:xml:ns:xmpp-tls) 
DEBUG: dispatcher info Registering protocol "default" as <class 'xmpp.protocol.Protocol'>(urn:ietf:params:xml:ns:xmpp-tls) 
DEBUG: dispatcher warn Registering protocol "proceed" as <class 'xmpp.protocol.Protocol'>(urn:ietf:params:xml:ns:xmpp-tls) 
DEBUG: dispatcher info Registering handler <bound method TLS.StartTLSHandler of <xmpp.transports.TLS instance at 0x199b908>> for "failure" type-> ns->(urn:ietf:params:xml:ns:xmpp-tls) 
DEBUG: dispatcher warn Registering protocol "failure" as <class 'xmpp.protocol.Protocol'>(urn:ietf:params:xml:ns:xmpp-tls) 
DEBUG: socket  sent <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/> 
DEBUG: socket  got <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/> 
DEBUG: dispatcher ok Got urn:ietf:params:xml:ns:xmpp-tls/proceed stanza 
DEBUG: dispatcher ok Dispatching proceed stanza with type-> props->[] id->None 
DEBUG: tls   ok Got starttls proceed response. Switching to TLS/SSL... 
DEBUG: dispatcher stop Plugging <xmpp.dispatcher.Dispatcher instance at 0x199b2d8> out of <xmpp.client.Client instance at 0x1988fc8>. 
DEBUG: dispatcher start Plugging <xmpp.dispatcher.Dispatcher instance at 0x19a4560> into <xmpp.client.Client instance at 0x1988fc8> 
DEBUG: dispatcher info Registering namespace "unknown" 
DEBUG: dispatcher info Registering protocol "unknown" as <class 'xmpp.protocol.Protocol'>(unknown) 
DEBUG: dispatcher info Registering protocol "default" as <class 'xmpp.protocol.Protocol'>(unknown) 
DEBUG: dispatcher info Registering namespace "http://etherx.jabber.org/streams" 
DEBUG: dispatcher info Registering protocol "unknown" as <class 'xmpp.protocol.Protocol'>(http://etherx.jabber.org/streams) 
DEBUG: dispatcher info Registering protocol "default" as <class 'xmpp.protocol.Protocol'>(http://etherx.jabber.org/streams) 
DEBUG: dispatcher info Registering namespace "jabber:client" 
DEBUG: dispatcher info Registering protocol "unknown" as <class 'xmpp.protocol.Protocol'>(jabber:client) 
DEBUG: dispatcher info Registering protocol "default" as <class 'xmpp.protocol.Protocol'>(jabber:client) 
DEBUG: dispatcher info Registering protocol "iq" as <class 'xmpp.protocol.Iq'>(jabber:client) 
DEBUG: dispatcher info Registering protocol "presence" as <class 'xmpp.protocol.Presence'>(jabber:client) 
DEBUG: dispatcher info Registering protocol "message" as <class 'xmpp.protocol.Message'>(jabber:client) 
DEBUG: dispatcher info Registering handler <bound method Dispatcher.streamErrorHandler of <xmpp.dispatcher.Dispatcher instance at 0x19a4560>> for "error" type-> ns->(http://etherx.jabber.org/streams) 
DEBUG: dispatcher warn Registering protocol "error" as <class 'xmpp.protocol.Protocol'>(http://etherx.jabber.org/streams) 
DEBUG: socket  sent <?xml version='1.0'?> 
    <stream:stream xmlns="jabber:client" to="localhost" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" > 
DEBUG: socket  sent <iq to="localhost" type="get" id="1"> 
    <query xmlns="jabber:iq:register" /> 
    </iq> 
DEBUG: dispatcher wait Waiting for ID:1 with timeout 25... 
DEBUG: socket  got <?xml version='1.0' encoding='UTF-8'?> 
    <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="mymachine" id="1724a327" xml:lang="en" version="1.0"> 
    <stream:features> 
    <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"> 
    <mechanism>DIGEST-MD5</mechanism> 
    <mechanism>PLAIN</mechanism> 
    <mechanism>ANONYMOUS</mechanism> 
    <mechanism>CRAM-MD5</mechanism> 
    </mechanisms> 
    <compression xmlns="http://jabber.org/features/compress"> 
    <method>zlib</method> 
    </compression> 
    <auth xmlns="http://jabber.org/features/iq-auth"/> 
    <register xmlns="http://jabber.org/features/iq-register"/> 
    </stream:features> 
DEBUG: dispatcher warn Unknown stanza: features 
DEBUG: dispatcher ok Dispatching unknown stanza with type-> props->[u'urn:ietf:params:xml:ns:xmpp-sasl', u'http://jabber.org/features/compress', u'http://jabber.org/features/iq-auth', u'http://jabber.org/features/iq-register'] id->None 
DEBUG: socket  got <iq type="error" id="1" from="localhost" to="mymachine/1724a327"> 
    <query xmlns="jabber:iq:register"/> 
    <error code="400" type="modify"> 
    <bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/> 
    </error> 
    </iq> 
DEBUG: dispatcher ok Got jabber:client/iq stanza 
DEBUG: dispatcher ok Dispatching iq stanza with type->error props->[u'jabber:iq:register', u'jabber:client'] id->1 
DEBUG: dispatcher ok Expected stanza arrived! 
DEBUG: socket  sent <iq to="localhost" type="set" id="2"> 
    <query xmlns="jabber:iq:register"> 
    <username>foo</username> 
    <password>bar</password> 
    </query> 
    </iq> 
DEBUG: dispatcher wait Waiting for ID:2 with timeout 25... 
DEBUG: socket  got <iq type="error" id="2" from="localhost" to="mymachine/1724a327"> 
    <query xmlns="jabber:iq:register"> 
    <username>foo</username> 
    <password>bar</password> 
    </query> 
    <error code="400" type="modify"> 
    <bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/> 
    </error> 
    </iq> 
DEBUG: dispatcher ok Got jabber:client/iq stanza 
DEBUG: dispatcher ok Dispatching iq stanza with type->error props->[u'jabber:iq:register', u'jabber:client'] id->2 
DEBUG: dispatcher ok Expected stanza arrived! 
Error! 
+0

從客戶端構造函數中刪除',debug = []'部分,如果不清楚答案是什麼,請在此處發佈協議。 – 2013-04-08 21:43:46

+0

我刪除了',debug = []並再次嘗試。我已通過編輯將錯誤消息發佈到我的問題中。協議指的是什麼? – Greenhand 2013-04-09 03:11:54

回答

1

最常見的錯誤,假設你要連接,是用戶已經存在,或者服務器不支持註冊。

然而,上面顯示你的錯誤跟蹤你得到一個錯誤400,而不是一個403409403意味着註冊已關閉,並且409意味着該用戶已存在。

我能夠通過發送到一個無效的JID複製您的問題與OpenFire 3.8.1。當您配置OpenFire時,您可以指定一個域。該域必須位於您在Python腳本的命令行中指定的JID中。例如,我在配置時指定了「localhost」。當我使用「[email protected]」而不是「[email protected]」時,我得到了400錯誤。如果你需要的域名是由計算機名(很常見的)不同,則要麼使用DNS SRV記錄(見RFC 6120, section 3.2),或更改Python代碼,使這條線:

cli=xmpp.Client(jid.getDomain()) 

是這樣的:

cli=xmpp.Client("hostname") 

後者是一個快速的黑客,而是應該讓你和運行。

+0

是否有一個輸入錯誤「例如,我在配置時指定了」localhost「,當我使用」foo @ mymachine「而不是」foo @ localhosthost「時,我得到了400錯誤。 foo @ localhosthost是不是foo @ localhost? – Greenhand 2013-04-11 12:46:27

+0

如果我想使用DNS SRV記錄,是否意味着我應該將DNS服務器(如bind9)安裝到運行Openfire的服務器上? – Greenhand 2013-04-11 12:47:41

+0

是的,有localhosthost是一個錯字。固定。 – 2013-04-11 19:38:29