connection error with GTALK #68

Closed
demonlj opened this Issue Dec 19, 2011 · 5 comments

Projects

None yet

5 participants

@demonlj
demonlj commented Dec 19, 2011

I followed the document to modified the simple client example like this, but i can only get ERROR!
system: UBUNTU 11.10 / TOMATO WRT
python: 2.7.2

=========================================MODIFIED SCRIPT===============================

!/usr/bin/python

-- coding: utf-8 --

"""
A simple client example.

The script asks for a sender JID and password, target JID and a message.
Then, it connects to the sender's server and sends the message to the target
JID.
"""

import sys
import logging
from getpass import getpass

from pyxmpp2.jid import JID
from pyxmpp2.message import Message
from pyxmpp2.client import Client
from pyxmpp2.settings import XMPPSettings
from pyxmpp2.interfaces import EventHandler, event_handler, QUIT
from pyxmpp2.streamevents import AuthorizedEvent, DisconnectedEvent

class MyHandler(EventHandler):
def init(self, target_jid, message):
self.target_jid = target_jid
self.message = message

@event_handler(AuthorizedEvent)
def handle_authorized(self, event):
    message = Message(to_jid = self.target_jid, body = self.message)
    event.stream.send(message)
    event.stream.disconnect()

@event_handler(DisconnectedEvent)
def handle_disconnected(self, event):
    return QUIT

@event_handler()
def handle_all(self, event):
    logging.info(u"-- {0}".format(event))

logging.basicConfig(level = logging.DEBUG) # change to 'DEBUG' to see more

your_jid = 'GTALK1@gmail.com'
your_password = 'MY PASSWORD'
target_jid = 'GTALK2@gmail.com'
message = 'is a message'

handler = MyHandler(JID(target_jid), message)
settings = XMPPSettings({
u"password": your_password,
u"starttls": True,
u"tls_verify_peer": False,
u"server":'talk.google.com',
u"c2s_port":5223,
})
client = Client(JID(your_jid), [handler], settings)
client.connect()
client.run()
=================================ERROR MESSAGE==========================
DEBUG:pyxmpp2.transport: _set_state('resolve-hostname')
DEBUG:pyxmpp2.mainloop.events: dispatching...
DEBUG:pyxmpp2.mainloop.events: queue empty
DEBUG:pyxmpp2.mainloop.poll: preparing handler: <pyxmpp2.transport.TCPTransport object at 0x1ab8050>
DEBUG:pyxmpp2.transport:TCPTransport.prepare(): state: 'resolve-hostname'
DEBUG:pyxmpp2.transport: _set_state('resolving-hostname')
DEBUG:pyxmpp2.transport:_dst_nameports: [('talk.google.com', 5223)]
DEBUG:pyxmpp2.transport: _set_state('connect')
DEBUG:pyxmpp2.transport:TCP transport event: Resolving address of 'talk.google.com'...
DEBUG:pyxmpp2.transport:TCPTransport.prepare(): new state: 'connect'
DEBUG:pyxmpp2.mainloop.poll: prepare result: PrepareAgain(0)
DEBUG:pyxmpp2.mainloop.events: dispatching...
DEBUG:pyxmpp2.mainloop.events: event: <pyxmpp2.streamevents.ResolvingAddressEvent object at 0x1ab8a90>
DEBUG:pyxmpp2.mainloop.events: handlers: [(1, <bound method MyHandler.handle_all of <main.MyHandler object at 0x1ab0b90>>)]
DEBUG:pyxmpp2.mainloop.events: passing the event to: <bound method MyHandler.handle_all of <main.MyHandler object at 0x1ab0b90>>
INFO:root:-- Resolving address of 'talk.google.com'...
DEBUG:pyxmpp2.mainloop.events: dispatching...
DEBUG:pyxmpp2.mainloop.events: queue empty
DEBUG:pyxmpp2.mainloop.poll: preparing handler: <pyxmpp2.transport.TCPTransport object at 0x1ab8050>
DEBUG:pyxmpp2.transport:TCPTransport.prepare(): state: 'connect'
DEBUG:pyxmpp2.transport:Connect error: [Errno 101] Network is unreachable
DEBUG:pyxmpp2.transport: _set_state('connect')
DEBUG:pyxmpp2.transport:TCPTransport.prepare(): new state: 'connect'
DEBUG:pyxmpp2.mainloop.poll: prepare result: PrepareAgain()
DEBUG:pyxmpp2.mainloop.events: dispatching...
DEBUG:pyxmpp2.mainloop.events: queue empty
DEBUG:pyxmpp2.mainloop.poll: preparing handler: <pyxmpp2.transport.TCPTransport object at 0x1ab8050>
DEBUG:pyxmpp2.transport:TCPTransport.prepare(): state: 'connect'
DEBUG:pyxmpp2.transport:Connect error: [Errno 115] Operation now in progress
DEBUG:pyxmpp2.transport: _set_state('connecting')
DEBUG:pyxmpp2.transport:TCP transport event: Connecting to 74.125.71.125:5223...
DEBUG:pyxmpp2.transport:TCPTransport.prepare(): new state: 'connecting'
DEBUG:pyxmpp2.mainloop.poll: prepare result: PrepareAgain()
Traceback (most recent call last):
File "send_message_client.py", line 59, in
client.run()
File "/usr/local/lib/python2.7/dist-packages/pyxmpp2-2.0alpha2_git-py2.7.egg/pyxmpp2/client.py", line 216, in run
self.main_loop.loop(timeout)
File "/usr/local/lib/python2.7/dist-packages/pyxmpp2-2.0alpha2_git-py2.7.egg/pyxmpp2/mainloop/base.py", line 86, in loop
self.loop_iteration(interval)
File "/usr/local/lib/python2.7/dist-packages/pyxmpp2-2.0alpha2_git-py2.7.egg/pyxmpp2/mainloop/poll.py", line 131, in loop_iteration
self._configure_io_handler(handler)
File "/usr/local/lib/python2.7/dist-packages/pyxmpp2-2.0alpha2_git-py2.7.egg/pyxmpp2/mainloop/poll.py", line 66, in _configure_io_handler
self.poll.unregister(old_fileno)
KeyError: 3

demonlj commented Dec 19, 2011

If I try the ECHOBOT.PY, there will be no ERROR MESSAGE, BUT still FAILED CONNECTION

jason >>> python echobot.py --starttls --tls-require --c2s-port 5223 --server talk.google.com --trace --password PASSWORD ACCOUNT@gmail.com
enabling trace
INFO:root:-- Resolving address of 'talk.google.com'...
INFO:root:-- Connecting to 74.125.71.125:5223...
OUT: '<stream:stream version="1.0" to="gmail.com" xml:lang="en" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">'
INFO:root:-- Connected to 74.125.71.125:5223
IN: ''
OUT: '/stream:stream'
INFO:root:-- Disconnected from ('74.125.71.125', 5223)

I have same error message, did you fix it?

demonlj commented Feb 3, 2012

sorry, I did not~

On Thu, Feb 2, 2012 at 11:26 PM, healthkxy <
reply@reply.github.com

wrote:

I have same error message, did you fix it?


Reply to this email directly or view it on GitHub:
#68 (comment)

Jason Lin

The Department of Orthopedics
The First Affiliated Hospital of Soochow University
188 Shizi Street, Suzhou, China. 215006
E-mail: jasonosfc@gmail.com

Mobile:0086-13732621361, 0086-18913165996

ֿ
ݴѧһҽԺǿ
ʮ188ţ215006
jasonosfc@gmail.com
ֻ0086-13732621361, 0086-18913165996

I have same error message too.

Contributor

Hi, I think I've found out the cause and have sent a pull request at #70, please review.

@Jajcus Jajcus closed this in bb7efe2 Feb 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment