2012-09-03 2 views
0

저는이 문제로 제 머리를 찢어 버릴 것입니다. 나는 xmppy를 테스트하기 위해 생각할 수있는 가장 단순한 코드를 사용하고 있으며, 그것은 반복적으로 실패한다. 과거에 sendxmpp를 사용했지만 일부 서버 측 스크립트를 sendxmpp로 출력하는 대신 파이썬을 사용하도록 마이그레이션하려고합니다. 어쨌든gtalk에 연결하는 중에 xmpppy 오류가 발생했습니다.

: 여기에 코드입니다 :

import xmpp 

user = "[email protected]" 
password = "actualPassword" 
server = 'talk.google.com' 

jid = xmpp.JID(user) 
connection = xmpp.Client(server) 
connection.connect() 

가 그리고 여기에 결과 출력입니다 :

Invalid debugflag given: always 
Invalid debugflag given: nodebuilder 
DEBUG: 
DEBUG: Debug created for /Users/ben/Desktop/PythonScripts/XMPP/xmpp/client.py 
DEBUG: flags defined: always,nodebuilder 
DEBUG: socket  start Plugging <xmpp.transports.TCPsocket instance at 0x108daae60> into <xmpp.client.Client instance at 0x108daad88> 
DEBUG: socket  warn An error occurred while looking up _xmpp-client._tcp.talk.google.com 
DEBUG: socket  start Successfully connected to remote host ('talk.google.com', 5222) 
DEBUG: dispatcher start Plugging <xmpp.dispatcher.Dispatcher instance at 0x108dbd050> into <xmpp.client.Client instance at 0x108daad88> 
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 0x108dbd050>> 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="talk.google.com" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" > 
DEBUG: socket  got <stream:stream from="talk.google.com" id="B0E6462206621A27" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client"> 
    <stream:features> 
    <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"> 
    <required/> 
    </starttls> 
    <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"> 
    <mechanism>X-GOOGLE-TOKEN</mechanism> 
    <mechanism>X-OAUTH2</mechanism> 
    </mechanisms> 
    </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'] id->None 
DEBUG: tls   start Plugging <xmpp.transports.TLS instance at 0x108dbda28> into <xmpp.client.Client instance at 0x108daad88> 
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 0x108dbda28>> 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 0x108dbda28>> 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 <stream:error> 
    <host-unknown xmlns="urn:ietf:params:xml:ns:xmpp-streams"/> 
    <str:text xmlns:str="urn:ietf:params:xml:ns:xmpp-streams">Set the 'to' attribute of stream element to the domain part of the user's JID. Example: to='gmail.com'.</str:text> 
    </stream:error> 
    </stream:stream> 
DEBUG: dispatcher ok Got http://etherx.jabber.org/streams/error stanza 
DEBUG: dispatcher ok Dispatching error stanza with type-> props->[u'urn:ietf:params:xml:ns:xmpp-streams'] id->None 
Traceback (most recent call last): 
    File "./sendXMPP.py", line 16, in <module> 
    print connection.connect() 
    File "/Users/ben/Desktop/PythonScripts/XMPP/xmpp/client.py", line 205, in connect 
    while not self.TLS.starttls and self.Process(1): pass 
    File "/Users/ben/Desktop/PythonScripts/XMPP/xmpp/dispatcher.py", line 303, in dispatch 
    handler['func'](session,stanza) 
    File "/Users/ben/Desktop/PythonScripts/XMPP/xmpp/dispatcher.py", line 215, in streamErrorHandler 
    raise exc((name,text)) 
xmpp.protocol.HostUnknown: (u'host-unknown', u"Set the 'to' attribute of stream element to the domain part of the user's JID. Example: to='gmail.com'.") 

내가 잘못 여기서 도대체 뭐하는 거지?

편집 : 변경 사항을 표시하는 코드가 업데이트되었습니다.

새로운 코드 :

import xmpp 

user = "[email protected]" 
password = "actualPassword" 
server = 'talk.google.com' 

jid = xmpp.JID(user) 
connection = xmpp.Client(jid.getDomain()) 
connection.connect() 
result = connection.auth(jid.getNode(), password,"TESTING") 

새로운 오류 : 수동으로 서버 설정 안

Invalid debugflag given: always 
Invalid debugflag given: nodebuilder 
DEBUG: 
DEBUG: Debug created for /Users/ben/Desktop/PythonScripts/XMPP/xmpp/client.py 
DEBUG: flags defined: always,nodebuilder 
DEBUG: socket  start Plugging <xmpp.transports.TCPsocket instance at 0x1033c0e60> into <xmpp.client.Client instance at 0x1033c0d88> 
DEBUG: socket  warn An error occurred while looking up _xmpp-client._tcp.gmail.com 
DEBUG: socket  error Failed to connect to remote host ('gmail.com', 5222): Operation timed out (60) 
Traceback (most recent call last): 
    File "/Users/ben/Desktop/PythonScripts/XMPP/xmpp/transports.py", line 133, in connect 
    self._sock.connect((server[0], int(server[1]))) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth 
    return getattr(self._sock,name)(*args) 
error: [Errno 60] Operation timed out 
DEBUG: socket  stop Plugging <xmpp.transports.TCPsocket instance at 0x1033c0e60> out of <xmpp.client.Client instance at 0x1033c0d88>. 

Traceback (most recent call last): 
    File "./sendXMPP.py", line 17, in <module> 
    result = connection.auth(jid.getNode(), password,"LFY-client") 
    File "/Users/ben/Desktop/PythonScripts/XMPP/xmpp/client.py", line 214, in auth 
    while not self.Dispatcher.Stream._document_attrs and self.Process(1): pass 
AttributeError: Client instance has no attribute 'Dispatcher' 
+0

오타의 서버. 미안. 코드가 변경되었습니다. – HeWhoWas

+0

음, 업데이트 된 추적 코드가 업데이트 된 코드에 전혀 맞지 않습니다. 오류는 17 행에 있지만 코드에는 7 행만 포함되어 있습니다. 실제 코드를 게시 할 수 있습니까? (http://sscce.org/)? 또한 DNS 서버가 올바르게 구성되었는지 확인하십시오.이 파일은'_xmpp-client._tcp.gmail.com'에 대한 SRV 레코드 중 상당수 여야합니다. 의심스러운 경우 [8.8.8.8] (https://developers.google.com/speed/public-dns/)으로 설정하십시오. – phihag

+0

업데이트 할 코드가 컴파일되어야합니다. 누락 된 유일한 행은 connection.auth() 행이며, 이제 추가되었습니다. (nslookup을 사용하여) 주소에 대한 DNS 항목이 있는지 확인했습니다. 도움을 주셔서 감사합니다. – HeWhoWas

답변

1

-xmpp.Client은 자신에 그것을 알아 내기 위해 노력할 것입니다 :

import xmpp 

jid = xmpp.JID("[email protected]") 
connection = xmpp.Client(jid.getDomain()) 
connection.connect() 

을 잘 작동해야합니다.

+0

그건 원래의 생각 이었지만, 그 방법을 사용할 때까지 내가 할 수 없었던 것조차도 얻을 수 없었습니다. 나는 동일한 코드를 사용할 때 일어나는 일의 결과를 보여주기 위해 원래의 질문을 업데이트했다. – HeWhoWas

+0

환경 문제가 없기 때문에이 수정 없이도 응용 프로그램이 작동하지 않았으므로이 대답을 수락했습니다. 감사 :-) – HeWhoWas

관련 문제