From: Norman R. <no...@ra...> - 2010-05-31 13:53:53
|
You must call cl.Process(<timeout>) as part of your loop, so that incoming messages are processed. You can do this instead of your time.sleep On Mon, May 31, 2010 at 2:16 PM, Cyril LAVIER <cla...@lt...<clavier%2Bx...@lt...> > wrote: > Hi. > > I'm coding a simple jabber bot using xmpppy, and after some hours, it > stops sending messages. > > The bot is quite silly, it simply reads a file, and sending the content > to a muc. > > The main problem is, after some hours of running. > > I added a "wake up" send every minute, it sends a blank message (like I > saw in some old messages on the mailing list), but it always do the same > problem. > > Here is the main loop, which reads the file, sends the message in the > file, and sends a "wake up" message every minute. > > cl is a client created using > "cl=xmpp.client.Client(jid.getDomain(),debug=['always'])" > > conference.room is a variable containing the conference room which will > receive the message. > > jabber.jid is the variable containing the complete JID of the user to > connect. > > Here is the part of the code containing the loop which reads the file, > sends the message in the file, and sends a "wake up" message every minute. > > _____________________________ > > jid=xmpp.protocol.JID(jabber.jid) > cl=xmpp.client.Client(jid.getDomain(),debug=['always']) > > cl.connect() > cl.auth(jid.getNode(), jabber.jid_password) > cl.sendInitPresence() > > presenceto=conference.room+"/"+conference.username > presence = xmpp.protocol.Presence(to=presenceto) > presence.setTag('x',namespace = > xmpp.protocol.NS_MUC).setTagData('password',conference.room_password) > cl.send(presence) > > mtime = os.stat("/var/cache/mnb_server")[ST_MTIME] > timer=time.time() > n=1 > > while n==1: > readmtime = os.stat(CACHEFILE)[ST_MTIME] > if not readmtime == mtime: > f = open(CACHEFILE, "r") > readl = f.readline() > if readl.strip() == "____exit____": > n=2 > else: > > tosend=xmpp.Message(to=conference.room,typ='groupchat',body=readl.strip()) > id=cl.send(tosend) > open(LOGFILE, > "a+").write(time.strftime("[%d/%m/%Y - %H:%M:%S]")+"Message #"+str(id)+" > sent\n") > mtime = readmtime > f.close() > if time.time() > timer + 60: > idw = cl.send(xmpp.Message()) > open(LOGFILE, > "a+").write(time.strftime("[%d/%m/%Y - %H:%M:%S]")+"Wake Up > #"+str(idw)+"\n") > timer=time.time() > time.sleep(0.25) > > ______________________ > > In the debug prints, I see the "wake up" messages like this "DEBUG: > socket sent <message id="1511" />" > > And I see the regular messages like this (here, I simply send the > current date) : "DEBUG: socket sent <message > to="conferenceroom@conferenceserver" type="groupchat" > id="1513"><body>Fri May 28 08:53:39 GMT 2010</body></message>" > > I set the ejabberd2 server logs to debug, and when the message do not > arrive in the conference room, they are not displayed in the server logs. > > I hope somebody will find an answer to this issue. > > Thanks. > > -- > Cyril LAVIER | Systems Administrator | LTU Technologies > 132 Rue de Rivoli - 75001 Paris France > (tel) +33 (0)1 53 43 01 71 | (mail) cl...@lt... > LTU technologies - Making Sense of Visual Content | www.LTUtech.com > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Xmpppy-devel mailing list > Xmp...@li... > https://lists.sourceforge.net/lists/listinfo/xmpppy-devel > -- - Norman Rasmussen - Email: no...@ra... - Home page: http://norman.rasmussen.co.za/ |