Open soulfly opened 8 years ago
Best thing you can do to move this forward is to make a pull request.
Looks like the right way is to support 'optional' element https://tools.ietf.org/html/draft-cridland-xmpp-session-01#section-2.1
so if server returns 'optional' then the strophejs lib should skip this request.
I can confirm that skipping this step works fine on ejabber since at least ejabberd 16.09. I have this code in place:
if (!Strophe.avoidAuthSession && this.do_session) {
this._addSysHandler(this._sasl_session_cb.bind(this),
null, null, null, "_session_auth_2");
this.send($iq({type: "set", id: "_session_auth_2"})
.c('session', {xmlns: Strophe.NS.SESSION})
.tree());
} else {
this.authenticated = true;
this._changeConnectStatus(Strophe.Status.CONNECTED, null);
}
Where the avoidAuthSession is something I set to true when I know I'm going to be pointing at a new ejabberd. It is probably worth implementing the suggestion by @soulfly and properly checking if this step is optional so everyone can benefit from the skipped step. It leads to a noticeable improvement in connection setup time for clients a long way from the server where an extra round trip can be significant. This is especially handy on websockets where session attachment can't easily be done (previously when using BOSH I avoided the auth round trip costs by pre-authenticating on the server side and then allowing the client to do a much faster session attachment afterwards).
Looks like session establishment is still required by im.wordpress.com
, so we shouldn't drop it entirely. Checking for optional
makes sense.
I found one thing which we can actually omit:
and this is also mentioned here https://tools.ietf.org/html/rfc6121#page-112
Can we skip this step with Strophejs?