views:

117

answers:

1

I'm trying to use xmpppy for sending jabber-messages from a django-website. This works entirely fine.

However, the message only gets sent to the -first- of the recipients in the list. This happens when I run the following function from django, and also if I run it from an interactive python-shell. The weird part though, is that if I extract the -body- of the function and run that interactively, then all the recipients (there's just 2 at the moment) get the message.

Also, I do know that the inner for-loop gets run the correct count times (2), because the print-statement does run twice, and return two different message-ids.

The function looks like this:

def hello_jabber(request, text):
    jid=xmpp.protocol.JID(settings.JABBER_ID)
    cl=xmpp.Client(jid.getDomain(),debug=[])
    con=cl.connect()
    auth=cl.auth(jid.getNode(),settings.JABBER_PW,resource=jid.getResource())
    for friend in settings.JABBER_FRIENDS:
        id=cl.send(xmpp.protocol.Message(friend,friend + ' is awesome:' + text))
        print 'sent message with id ' + str(id)
    cl.disconnect()
    return render_to_response('jabber/sent.htm', locals())
A: 

Activate the debug options in xmpppy to see what does the xmpp client.

naw
Tried that now. It didn't seem to do a lot, though it generated an error, but the error seems to be related to ps2 being undefined/closed in django. (stands to reason, I assume that's stderr on unix and that debug-info goes there) Here's the relevant output: DEBUG: socket sent <message to="[email protected]" from="[email protected]/xmpppy" id="3"> DEBUG: socket sent <message to="[email protected]" from="[email protected]/xmpppy" id="4"> DEBUG: socket error Socket error while receiving dataAttributeError: 'module' object has no attribute 'ps2'
Agrajag
More research show that if I run the same code from python (without django), as expected the complaints about ps2 goes away, BUT I still get the "Socket error while receiving data" "client: stop Disconnect detected". So django is innocent :-) Still a mystery why running that code as a -function- bombs whereas running it inline in the python-interpreter does not, though.
Agrajag