Slixmpp
raw JSON → 1.14.1 verified Mon Apr 27 auth: no python
Slixmpp is an elegant Python library for XMPP (aka Jabber), designed for event-driven, asynchronous communication. Current version is 1.14.1, supporting Python >=3.11. Release cadence is irregular, with a focus on stability and async compatibility.
pip install slixmpp Common errors
error ImportError: cannot import name 'ClientXMPP' from 'slixmpp' ↓
cause Incorrect installation or using a very old version (pre-fork).
fix
Ensure you have the correct package: pip install slixmpp. The import is 'from slixmpp import ClientXMPP'.
error TypeError: object NoneType can't be used in 'await' expression ↓
cause Calling xmpp.process() without awaiting it inside an async function.
fix
Use 'await xmpp.process()' inside an async function, or use the synchronous version by calling xmpp.process(block=False).
error ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed ↓
cause Slixmpp verifies SSL certificates by default, but the server certificate is self-signed or invalid.
fix
For development, disable SSL verification: xmpp = ClientXMPP(jid, password, ssl=False). For production, configure proper CA certificates.
error AttributeError: 'module' object has no attribute 'Iq' ↓
cause Importing 'Iq' (uppercase 'I') instead of 'Iq' (capital I lowercase q) or wrong casing.
fix
Use 'from slixmpp import Iq' (capital I, lowercase q). The stanza class is 'Iq', not 'IQ'.
Warnings
breaking Slixmpp dropped support for Python <3.11 in version 1.14.0. ↓
fix Upgrade to Python 3.11 or later, or pin to slixmpp<1.14.0 if stuck on older Python.
deprecated The 'message' event handler 'on_message' pattern is deprecated; use 'add_event_handler("message", callback)' instead. ↓
fix Use add_event_handler with event names as strings.
gotcha Slixmpp uses asyncio; do not use time.sleep() inside event handlers as it blocks the event loop. ↓
fix Use await asyncio.sleep() instead of time.sleep().
gotcha When connecting without TLS, many servers require explicit setup; Slixmpp may reject insecure connections by default. ↓
fix Set socket.ssl_version to ssl.PROTOCOL_TLS_CLIENT or disable SSL verification with caution.
Imports
- ClientXMPP wrong
import sleekxmppcorrectfrom slixmpp import ClientXMPP - ComponentXMPP
from slixmpp import ComponentXMPP - IQ wrong
from slixmpp.stanza import IQcorrectfrom slixmpp import Iq - JID
from slixmpp import JID
Quickstart
import asyncio
from slixmpp import ClientXMPP
class EchoBot(ClientXMPP):
def __init__(self, jid, password):
super().__init__(jid, password)
self.add_event_handler("session_start", self.start)
self.add_event_handler("message", self.message)
async def start(self, event):
self.send_presence()
self.get_roster()
async def message(self, msg):
if msg['type'] in ('chat', 'normal'):
msg.reply("Thanks for sending: " + msg['body']).send()
async def main():
xmpp = EchoBot('user@example.com', 'password')
xmpp.connect()
await xmpp.process()
asyncio.run(main())