Instantly share code, notes, and snippets.

What would you like to do?
A Strophe plugin by iAdvize that use the XdomainRequest if found (Internet Explorer)
Strophe.addConnectionPlugin("xdomainrequest", {
init: function () {
if (window.XDomainRequest) {
Strophe.debug("using XdomainRequest for IE");
// override thee send method to fire readystate 2
XDomainRequest.prototype.oldsend = XDomainRequest.prototype.send;
XDomainRequest.prototype.send = function() {
XDomainRequest.prototype.oldsend.apply(this, arguments);
this.readyState = 2;
try {
} catch (e) {}
// replace Strophe.Request._newXHR with the xdomainrequest version
Strophe.Request.prototype._newXHR = function () {
var fireReadyStateChange = function (xhr, status) {
xhr.status = status;
xhr.readyState = 4;
try {
} catch (e) {}
var xhr = new XDomainRequest();
xhr.readyState = 0;
xhr.onreadystatechange = this.func.bind(null, this);
xhr.onload = function () {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xhr.responseXML = xmlDoc;
fireReadyStateChange(xhr, 200);
xhr.onerror = function () {
fireReadyStateChange(xhr, 500);
xhr.ontimeout = function () {
fireReadyStateChange(xhr, 500);
return xhr;
} else {
Strophe.error("XDomainRequest not found. Falling back to native XHR implementation.");

This comment has been minimized.

dhruvasagar commented Jul 26, 2012

Thanks for this, works like a charm :)


This comment has been minimized.


kenstir commented Jul 27, 2012

You are quite welcome, I'm happy to share and share alike!


This comment has been minimized.

freehn commented Aug 14, 2012

Thanks a loooooooooooooooooooot!! it works very smoothly.


This comment has been minimized.

esromneb commented Mar 19, 2013

Works great for me on IE9 win7. Just a note: I had to put this at the bottom of strophe.js right after:

if (callback) {
callback(Strophe, $build, $msg, $iq, $pres);


This comment has been minimized.

xecarus commented Sep 11, 2013

I am new to strophe, and I have a question about how to use that js file? could you post me some example



This comment has been minimized.

RahulGupta1986 commented Apr 4, 2014



This comment has been minimized.

RahulGupta1986 commented Apr 4, 2014

Could anyone please let me know how to use strophe plugin,.....I am new to conversejs..

When I am doing prebind true and IE is 8 then only i am not able to connect XMPP server and getting below error...

Kindly help me on this...Thanks in advance!

2014.04.04 16:06:36 - SASLAuthentication: SaslException DIGEST-MD5: digest response format violation. Mismatched response.
at Source)
at Source)
at org.jivesoftware.openfire.SessionPacketRouter.route(
at org.jivesoftware.openfire.http.HttpSession.sendPendingPackets(
at org.jivesoftware.openfire.http.HttpSessionManager$
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$ Source)
at Source)


This comment has been minimized.

shaggybb commented Apr 9, 2015

I've found a looping request on IE9 when user loses connection after some time of inactivity.

The server returns this message:
2015-04-09 10:43:18.674 [pool-11-thread-7] BoshConnectionManager.processSocketData() INFO: There is no session with given SID = 6b9698c7-0e37-40a2-bf8a-e7783a8958f0. Closing invalid connection

The client receives a 404 response but Strophe is not able to disconnect and try again ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment