注目すべき点:以下はhttps経由のクロスドメインで行われています。私は正直なところ、IE10、Chrome、FFではすべてがうまくいくので、これが問題だとは思わない。私の推測では、それはIE8のXDomainRequestオブジェクトの分散かもしれないということですか?確かに。Socket.IOとIE8 - jsonpポーリング接続が常に失敗する
sendLoginRequest
メソッドは、最初に呼び出されるメソッドです。他のすべてのサポートコードも以下に提供されています。
これはすべて非常に簡単ですが、なぜIE8が失敗するのかわかりません。
LOG:CONNECT_FAILED
'f.parentNode' is null or not an object
'f.parentNode' is null or not an object
LOG:CONNECT_FAILED
'f.parentNode' is null or not an object
'f.parentNode' is null or not an object
LOG:CONNECT_FAILED
'f.parentNode' is null or not an object
'f.parentNode' is null or not an object
LOG:CONNECT_FAILED
'f.parentNode' is null or not an object
'f.parentNode' is null or not an object
LOG:CONNECT_FAILED
'f.parentNode' is null or not an object
'f.parentNode' is null or not an object
LOG:CONNECT_FAILED
'f.parentNode' is null or not an object
'f.parentNode' is null or not an object
........:私は両方のコンソールで見ていますとフィドラー ポーリングが発生し、実際にあるが、同じ失敗は、各世論調査では発生し続ける
function WrappedSocket(data, session_string) {
var clientSocket = io.connect('https://xxxxxxxx/socketio', { query: "session=" + encodeURIComponent(session_string), transports: ['jsonp-polling'] });
clientSocket.socket.on("connect", function() { console.log("CONNECT_SUCCEED"); });
clientSocket.socket.on("connect_failed", function() { console.log("CONNECT_FAILED"); });
clientSocket.socket.on("reconnect_failed", function() { console.log("RECONNECT_FAILED"); });
clientSocket.socket.on("error", function (eobj) { console.log("Socket error " + eobj); });
console.log("Made a socket that is talking");
}
var my_socket;
function set_up_socket(data, sessionString) {
setSession(data.responseText);
my_socket = new WrappedSocket(data, sessionString);
my_socket.socket.emit("message", "Howdy!");
}
function sendLoginRequest(loginCode, nextRequest) {
var xhr = createCORSRequest('POST', 'https://xxxxx/login', false);
var sessionString = 'xxxx';
if ("withCredentials" in xhr) {
xhr.addEventListener("load", function() {
set_up_socket(this, sessionString);
}, false);
}
else {
xhr.onload = function() {
set_up_socket(this, sessionString);
};
}
xhr.send();
}
function createCORSRequest(method, url, onload) {
xhrObj = new XMLHttpRequest();
if ("withCredentials" in xhrObj) {
// Check if the XMLHttpRequest object has a "withCredentials" property.
// "withCredentials" only exists on XMLHTTPRequest2 objects.
if (onload) {
xhrObj.addEventListener("load", onload, false);
}
xhrObj.open(method, url, true);
xhrObj.withCredentials = true;
} else if (typeof XDomainRequest != "undefined") {
// Otherwise, check if XDomainRequest.
// XDomainRequest only exists in IE, and is IE's way of making CORS requests.
xhrObj = new XDomainRequest();
xhrObj.open(method, url);
if (onload) {
xhrObj.onload = onload;
}
} else {
// Otherwise, CORS is not supported by the browser.
xhrObj = null;
}
return xhrObj;
}
エラー....
(あなたがアイデアを得る、これはそれをポーリングとして何度も発生します。)
ここでも、各要求Fを見ることができますサーバーからの200件すべての応答が次々と送信されますが、すべてがCONNECT_FAILEDとなり、socket.io.jsファイルのJSエラーが発生します。
最後に、コンソールスクリーンショット(上記の「f.parentNodeはnullまたはオブジェクトではありません」)で上記のエラーで破損しているクライアント上のsocket.io.jsファイルのコードを示します。私はオブジェクトがnullであることを理解しています、なぜ私はそれがnullであるかは分かりません。
........
if (this.isXDomain() && !io.util.ua.hasCORS) {
var insertAt = document.getElementsByTagName('script')[0]
, script = document.createElement('script');
script.src = url + '&jsonp=' + io.j.length;
insertAt.parentNode.insertBefore(script, insertAt);
io.j.push(function (data) {
complete(data);
script.parentNode.removeChild(script); // *** BREAKS HERE!! ***
});
.........
それは、私の問題の始まりが途絶えていたようです。問題の説明がありました。基本的に私が提供したコードはjsonp-pollingを使って単純なsocket.io接続を行います。私はすでに上記のすべての詳細とはうまく動作しません。探してくれてありがとう。 –
IE 9でも試しましたか?はいの場合、ヘッダー、doctype、すべてのパーツ、ボディのオープンタグまでHTMLコードで返信してください。実際の内容を変更することができます。あなたが素晴らしいことになるフィドルを作成することができれば。 – MarmiK
IE8は '.addEventListener()'をサポートしていますか?私はOperaが実際のイベントを使用していなかったか使用していなかったことを知っています。 –