Skip to content

Improve exception type and error message when connection to XMPP server fails #97

@amotl

Description

@amotl

Problem

When connecting to an XMPP server fails, the library raises a cryptic exception that does not quite reveal what's going on.

DEBUG: socket       start Plugging <xmpp.transports.TCPsocket object at 0x105ae3620> into <xmpp.client.Client object at 0x105ae3380>
DEBUG: socket       warn  An error occurred while looking up _xmpp-client._tcp.localhost
DEBUG: socket       error Failed to connect to remote host ('localhost', 5222): Connection refused (61)
DEBUG: socket       stop  Plugging <xmpp.transports.TCPsocket object at 0x105ae3620> out of <xmpp.client.Client object at 0x105ae3380>.
Traceback (most recent call last):
  File "/path/to/xmpp-message", line 10, in <module>
    sys.exit(simple_message())
             ~~~~~~~~~~~~~~^^
  File "/path/to/xmpppy/xmpp/cli.py", line 74, in simple_message
    send_message(options.jabberid, options.password, options.receiver, options.message, debug=options.debug)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/xmpppy/xmpp/cli.py", line 27, in send_message
    retval = connection.auth(user=jid.getNode(), password=password, resource=jid.getResource())
  File "/path/to/xmpppy/xmpp/client.py", line 217, in auth
    while not self.Dispatcher.Stream._document_attrs and self.Process(1): pass
              ^^^^^^^^^^^^^^^
AttributeError: 'Client' object has no attribute 'Dispatcher'

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementA feature request, suggestion, or pitch.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions