fritzy / SleekXMPP

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

'message' event handler not working #483

Open ianling opened 6 years ago

ianling commented 6 years ago

I'm running a slightly stripped down version of the boiler plate in the repo's README:

import logging
from sleekxmpp import ClientXMPP
from sleekxmpp.exceptions import IqError, IqTimeout

class EchoBot(ClientXMPP):
    def __init__(self, jid, password):
        ClientXMPP.__init__(self, jid, password)
        self.add_event_handler("message", self.message)

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

if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG,
                        format='%(levelname)-8s %(message)s')

    xmpp = EchoBot('user', 'password')
    xmpp.connect(address=("server", 1234))
    xmpp.process(block=True)

I can see DEBUG: RECV: messages appearing in the log, so I know the client is definitely receiving messages, but the event handler isn't running:

DEBUG RECV: <message to="recipient" from="sender" type="normal"><body>ddsadsadsadsa</body></message>

This is on Python 3.6.4 on Windows 10 x86-64.

loctruong96 commented 6 years ago

I have the same problem. It turned out that if it missed the message. It message handler will start working again. If no new message is missed from previous logon session then Echo will stop working.

lalittech commented 5 years ago

I have the same issue on python 3.5 window 10 and centos 6 python 2.7 . Message appears in DEBUG logs but message callbacks is never going to receive this inside main class.

Neustradamus commented 5 years ago

@ianling @loctruong96 @lalittech: Have you tested with "master"?

It works?

If not, have you a patch? Can you create a PR?

ianling commented 5 years ago

I moved to a different library as I could not find a solution for this one.

Neustradamus commented 5 years ago

@ianling: It was the master version that you had tested or other? What do you use now? :/

ianling commented 5 years ago

It was likely master. I am currently using my fork of xmppgcm: https://github.com/ianling/xmppgcm

Neustradamus commented 5 years ago

Thanks for informations but I hope that one guy can solve this problem...

lalittech commented 5 years ago

Can we use sleek xmpp version 1.3.1 for production use.

Neustradamus commented 5 years ago

@lalittech: 1.3.2 works no? https://github.com/fritzy/SleekXMPP/releases

lalittech commented 5 years ago

@Neustradamus sleekxmpp v1.3.2 and v 1.3.3 is working. But with certificate expiration with max and approximately 3 months . But again still message event handlar is not working . Have you tested 1.3.1 version. If so let me know?