fritzy / SleekXMPP

Python 2.6+/3.1+ XMPP Library
http://groups.google.com/group/sleekxmpp-discussion
Other
1.1k stars 299 forks source link

session_start not working #463

Closed salmanasiddiqui closed 5 years ago

salmanasiddiqui commented 7 years ago
import sleekxmpp

class SendMsgBot(sleekxmpp.ClientXMPP):
    def __init__(self, jid, password, recipient, message):
        sleekxmpp.ClientXMPP.__init__(self, jid, password)
        self.recipient = recipient
        self.msg = message
        self.add_event_handler("session_start", self.start)
        self.add_event_handler("message", self.msg)

    def start(self, event):
        raise('it wont fail it wont end')
        self.send_presence()
        self.get_roster()

        self.send_message(mto=self.recipient,
                mbody=self.msg,
                mtype='chat')

    def message(self, msg):
        if msg['type'] in ('chat', 'normal'):
            msg.reply("Thanks for sending\n%(body)s" % msg).send()

if __name__ == '__main__':
    xmpp = SendMsgBot(
            'some jid',
            'password',
            'someother jid',
            'blahblah'
    )
    xmpp.register_plugin('xep_0030')  # Service Discovery
    xmpp.register_plugin('xep_0004')  # Data Forms
    xmpp.register_plugin('xep_0060')  # PubSub
    if xmpp.connect():
        xmpp.process(block=True)
        print("Done")
    else:
        print("Unable to connect.")

the above code should raise an exception as soon as the self.start is called but that wont happen. This code is similar to one of the examples in the repo. Without that raise it should complete the steps and disconnect, but that never happens aswell.

5aurabhpathak commented 6 years ago

I'm facing this issue as well. Any updates?

LisaOneLogic commented 6 years ago

I have the same issue. @5aurabhpathak did you find a solution?

Neustradamus commented 5 years ago

@salmanasiddiqui @5aurabhpathak @LisaOneLogic: Have you tested with "master"?

Always same? Have you a patch? Can you create a PR?

salmanasiddiqui commented 5 years ago

feel free to close this issue.. if it exists in the latest version, then someone will create another issue and will be able to provide more info

Neustradamus commented 5 years ago

@salmanasiddiqui What do you use now? :/

salmanasiddiqui commented 5 years ago

I was trying to use this to write some tests, ended up doing some manual testing using gui based xmpp clients, and then used jmeter for basic stress testing