Firebase - Is There A Flag To Force Long Polling When Websockets Are Blocked By Corporate Proxy/firewall?
I'm developing a simple corporate AngularJS app and was planning on using Firebase for the backend. The browsers I have to support are IE8 and Chrome (latest). I have managed to fi
Solution 1:
you can use Firebase.INTERNAL.forceLongPolling();
to force long polling Firebase.INTERNAL.forceWebSockets();
to force web socket
Solution 2:
I'm sure there is a better way but I just went in to firebase-debug.js and changed the following function:
fb.realtime.WebSocketConnection["isAvailable"] = function() {
var isOldAndroid = false;
if(typeof navigator !== "undefined" && navigator.userAgent) {
var oldAndroidRegex = /Android ([0-9]{0,}\.[0-9]{0,})/;
var oldAndroidMatch = navigator.userAgent.match(oldAndroidRegex);
if(oldAndroidMatch && oldAndroidMatch.length > 1) {
if(parseFloat(oldAndroidMatch[1]) < 4.4) {
isOldAndroid = true
}
}
}
return!isOldAndroid && fb.WebSocket !== null && !fb.realtime.WebSocketConnection.forceDisallow_
};
to instead read:
fb.realtime.WebSocketConnection["isAvailable"] = function() {
returnfalse
};
This worked, Chrome now long polls automatically and my app can communicate with Firebase. I made the same change to the minified firebase.js but would obviously prefer a more future-proof workaround instead of this hack if anyone can suggest one.
Post a Comment for "Firebase - Is There A Flag To Force Long Polling When Websockets Are Blocked By Corporate Proxy/firewall?"