xhr 폴링을 사용할 때 내 소켓 연결이 닫히지 않는 이유를 아는 사람이 있습니까? 이것은 실행하고 싶지만 xhr 폴링을 사용할 때 실행되지 않는 서버 코드입니다. 소켓 연결이 잘 작동합니다 (이 소켓은 보안 성이 뛰어나므로 스턴넬로 바니시 뒤에 있습니다). 브라우저 언로드시 끊어지는 이벤트를 수동으로 시도했지만 이것이 최적의 해결책은 아닙니다. 내 클라이언트 측 코드에서 XHR 폴링으로 소켓 연결 닫기
client.on('disconnect', function() {
delete connected_clients[id];
console.log(' debug - ' + 'client ' + client.id + 'is disconnected');
console.log(' debug - ' + 'total number of connected clients is ' + Object.keys(connected_clients).length);
});
는,이 같은 소켓을 연결하고있다 :
socket = io.connect(BASE_URL, {
"sync disconnect on unload":true
});
내 서버 측 설정은이 :
io.enable('browser client minification'); // send minified client
io.enable('browser client etag'); // apply etag caching logic based on version number
io.enable('browser client gzip'); // gzip the file
io.set('log level', 3); // reduce logging
io.set('match origin protocol', true); // ssl support
io.set('sync disconnect on unload', true);
io.set('transports', [ // enable all transports (optional if you want flashsocket)
'xhr-polling',
'websocket',
'flashsocket',
'htmlfile',
'jsonp-polling'
]);
이 내가 얻을 디버그 메시지입니다 클라이언트가 브라우저를 종료 할 때
debug: xhr-polling closed due to exceeded duration
노드 0.8.8에서 socket.io 버전 0.9.10을 사용하고 있습니다.