배경 : 웹 소켓 작성 중. Chrome에서 잘 작동합니다. 단일 연결. 파이어 폭스에서 잘 작동하지만, 두 개의 연결을 만든다. 나는 단서가 없다. 동일한 자바 스크립트, 동일한 웹 페이지, 동일한 소켓 서버.Firefox 웹 소켓 이중 연결
클라이언트 측 JS :
var ws;
doWebSocketSetup();
function doWebSocketSetup(){
console.log('Connecting...');
ws=new WebSocket('ws://mysocketserver.com:9300/demo');
ws.onopen=function(){
console.log('Connected!')
socketSend('connect',sessionStorage.user);
if(!sessionStorage.announce){
socketSend('login',sessionStorage.user);
sessionStorage.announce=true;
}
socketSend('view',window.location.href);
setTimeout(function(){
processQueue();
},100);
}
ws.onmessage=function(e){
if(e.data!='ok'){
$.msg(e.data,{header:'Server Message',live:10000});
console.log('Server: '+e.data);
}
processQueue();
}
ws.onclose=function(){
console.log('Disconnected');
}
}
var sendQueue=new Array();
function socketSend(action,data){
var payload = new Object()
payload.action = action
payload.client = sessionStorage.user
payload.data = data
sendQueue.unshift(payload);
}
function processQueue(){
if(sendQueue.length==0)
return;
var payload=sendQueue.pop()
console.log('Sending: '+JSON.stringify(payload));
ws.send(JSON.stringify(payload))
}
이제 파이어 폭스에서 서버 콘솔 출력 :
2012-10-18 20:58:53 [info] [client 68.99.226.57:53079] Connected 94e568176299729fa8669c512fdb107d
2012-10-18 20:58:53 [info] [client 68.99.226.57:53080] Connected 457eb971eabaeba6b6afd637755ce53c
2012-10-18 20:58:53 [info] [client 68.99.226.57:53080] Performing handshake
2012-10-18 20:58:53 [info] [client 68.99.226.57:53080] Handshake sent
2012-10-18 20:58:54 [info] [client 68.99.226.57:53080] _actionConnect
2012-10-18 20:58:54 [info] [client 68.99.226.57:53080] _actionView
2012-10-18 20:58:58 [info] [client 68.99.226.57:53079] Disconnected - 94e5681762 99729fa8669c512fdb107d
그리고 크롬에 :
2012-10-18 21:09:17 [info] [client 68.99.226.57:53161] Connected 3906f16fa4037cbb08a8a5d1d6094cea
2012-10-18 21:09:17 [info] [client 68.99.226.57:53161] Performing handshake
2012-10-18 21:09:17 [info] [client 68.99.226.57:53161] Handshake sent
2012-10-18 21:09:17 [info] [client 68.99.226.57:53161] _actionConnect
2012-10-18 21:09:17 [info] [client 68.99.226.57:53161] _actionView
당신은 크롬에서 하나의 연결을 참조하십시오 적절한 핸드 셰이크와 액션이 호출됩니다. 파이어 폭스에서는 두 개의 연결이 정확히 같은 시간에 하나의 핸드 셰이 킹 (handshake)과 액션 (브라우저에서 의도 한대로)을 수행하지만, 두 번째 연결은 5 초 후에 시작됩니다. 이건 그냥 파이어 폭스 일인가요? 나는 Firebug에서 단 하나의 연결 인 두 개의 연결을 보여주지 않을 것이다. 파이어 폭스 일 뿐이라면 정확한 데이터가 보내지고 받아지기 때문에 나는 그걸로 살 수있다. 그러나 그렇다면 내 이마에 쭈그러 앉을 것이다.
글쎄, 네가 옳았 어. 나는 내가 최신 버전을 실행하고 있지 않다는 것을 깨닫지 못했다. 감사! –