-
-
Save kenstir/1095825 to your computer and use it in GitHub Desktop.
A Strophe plugin by iAdvize that use the XdomainRequest if found (Internet Explorer)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Strophe.addConnectionPlugin("xdomainrequest", { | |
init: function () { | |
if (window.XDomainRequest) { | |
Strophe.debug("using XdomainRequest for IE"); | |
// override the send method to fire readystate 2 | |
if (typeof XDomainRequest.prototype.oldsend == 'undefined') { | |
XDomainRequest.prototype.oldsend = XDomainRequest.prototype.send; | |
XDomainRequest.prototype.send = function() { | |
XDomainRequest.prototype.oldsend.apply(this, arguments); | |
this.readyState = 2; | |
try { | |
this.onreadystatechange(); | |
} 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 { | |
xhr.onreadystatechange(); | |
} 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"; | |
xmlDoc.loadXML(xhr.responseText); | |
xhr.responseXML = xmlDoc; | |
fireReadyStateChange(xhr, 200); | |
}; | |
xhr.onerror = function () { | |
Strophe.error("Strophe xdr.onerror called"); | |
fireReadyStateChange(xhr, 500); | |
}; | |
xhr.ontimeout = function () { | |
Strophe.error("Strophe xdr.ontimeout called"); | |
fireReadyStateChange(xhr, 500); | |
}; | |
return xhr; | |
} | |
} else { | |
Strophe.info("XDomainRequest not found. Falling back to native XHR implementation."); | |
} | |
} | |
}); |
Hi,
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
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 org.jivesoftware.openfire.net.SASLAuthentication - SASLAuthentication: SaslException
javax.security.sasl.SaslException: DIGEST-MD5: digest response format violation. Mismatched response.
at com.sun.security.sasl.digest.DigestMD5Server.validateClientResponse(Unknown Source)
at com.sun.security.sasl.digest.DigestMD5Server.evaluateResponse(Unknown Source)
at org.jivesoftware.openfire.net.SASLAuthentication.handle(SASLAuthentication.java:325)
at org.jivesoftware.openfire.SessionPacketRouter.route(SessionPacketRouter.java:66)
at org.jivesoftware.openfire.http.HttpSession.sendPendingPackets(HttpSession.java:645)
at org.jivesoftware.openfire.http.HttpSessionManager$HttpPacketSender.run(HttpSessionManager.java:419)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)