$(document).ready(function () { connection = new Strophe.Connection(BOSH_SERVICE); connection.connect( 'somehost', null, onConnect ); }); function onConnect(status) { if (status == Strophe.Status.DISCONNECTED) { // this means i've logged off as anonymous user, so log back in properly connection.connect('someuser@somehost', 'somepassword', onConnect); connection.addHandler(registerCreds, 'jabber:iq:register', 'iq', null, 'reg1', null); } else if (status == Strophe.Status.CONNECTED) { if(!REGISTERED) { // i'm logged in anonymously, so off i go to register register(); } connection.addHandler(registerCreds, 'jabber:iq:register', 'iq', null, 'reg1', null); connection.addHandler(acknowledgeCreds, 'jabber:iq:register', 'iq', null, 'reg2', null); $().mousemove(function(e){ sendMessageToListener(e.pageX, e.pageY); }) } } function register() { var iq = $iq( { "id":'reg1', "type":"get" }) .c("query", {"xmlns":"jabber:iq:register"}); connection.send(iq); return true; } function registerCreds(msg) { var iq = $iq( { "id":'reg2', "type":"set" }) .c("query", {"xmlns":"jabber:iq:register"}) .c('username').t(MY.user) .up() .c('password').t(MY.user); connection.send(iq); return true; } function acknowledgeCreds(msg) { REGISTERED = true; var iq = $iq( { 'id':'unreg1', 'type':'set', 'from': connection.jid }) .c('query',{'xmlns':'jabber:iq:register'}) .c('remove'); connection.send(iq); return true; }
I know that jabber.org added a parameter to limit in band registration
attempts. My guess is that you are hitting the rate limit for
registrations. If you control the server you might try disabling that
and see if that fixes the problem.
Thanks for posting the workaround, though. I never knew you could do
in-band registration when authenticated as SASL ANONYMOUS.
jack.
You aren't getting disconnected on a reload? That sounds very weird.
On a reload the old client may not get disconnected due to inactivity
timeouts, but Strophe should not have any knowledge of that at all.
Are you calling disconnect()? Perhaps turn on the debugging info (set
Strophe.log to function (lvl, msg) { console.log(msg); } for instance)
and find out what sequence of events is from its perspective?
jack.