Django + Strophe + ejabberd - troubles with attach and groupchat -
i try use strophe + ejabberd make webchat.
what i've done already:
- when login website, authenticate ejabberd (to achieve rid , sid),
- after login finished, attach rid , sid got context processor,
- connection status seems be: connection established, logs:
.
post: <body rid='406266360' xmlns='http://jabber.org/protocol/httpbind' sid='9c66aa19123e96dc2925c24d4f985d458763eb67'><presence xmlns='jabber:client'><priority>-1</priority></presence><presence to='localhost/m' xmlns='jabber:client'><x xmlns='http://jabber.org/protocol/muc'/></presence></body> resp: <body xmlns='http://jabber.org/protocol/httpbind'><success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/></body>
after that, connection hangs on:
post: <body rid='406266361' xmlns='http://jabber.org/protocol/httpbind' sid='9c66aa19123e96dc2925c24d4f985d458763eb67'/>
when try send message (while hanged):
post: <body rid='406266362' xmlns='http://jabber.org/protocol/httpbind' sid='175e45333109f74c36f9dffbe4e3cc6cffc80df4'><message to='localhost' type='groupchat' xmlns='jabber:client'><body>yrdy</body></message></body>
im getting:
resp: <body type='terminate' condition='remote-stream-error' xmlns='http://jabber.org/protocol/httpbind' xmlns:stream='http://etherx.jabber.org/streams'><stream:error><xml-not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error></body>
whats wrong? strange thing after seconds request aborted, , next request hangs again. when try send message then, there no errors response is:
resp: <body xmlns='http://jabber.org/protocol/httpbind'/>
with no errors (connection still connected , authenticated, message doesnt seem delivered).
code use send message:
var body = $('#input_text').val(); | // make sure presence right room var msg_body = { | if (room === groupie.room) { to: chat.room, | var nick = strophe.getresourcefromjid(from); type: 'groupchat' | } | if ($(presence).attr('type') === 'error' && var msg = $msg(msg_body).c('body').t(body); | !groupie.joined) { | // error joining room; reset app chat.connection.send(msg);
you can use strophe.js attach so:
chat.connection = new strophe.connection(chat.bosh_service_url); chat.connection.attach(jid, sid, rid, onconnecthandler);
onconnecthandler called once you've attached successfully. one, don't have worry sid , rid again (until page reload).
also, aware of muc strophe plugin?
if want example code use/study, wrote similar you're doing plone, called collective.xmpp.chat
the javascript reusable separately: converse.js
Comments
Post a Comment