我正在构建一个使用socket.io和Web Worker api每秒从服务器获取更新的Web应用程序。其中一个按钮正在打开一个新窗口,当打开新窗口时,socket.io停止工作并收到错误的请求响应
//part of the code
var socket = io({transports: ['polling']});
worker = new Worker("web_worker.js");
worker.onmessage = function(event){
socket.emit("check_for_updates");
}
//this function is called when a button is pressed
function new_window(client)
{
var uid = client.uid;
var new_window = window.open("/new?uid="+uid);
}
控制台中显示的错误:
polling-xhr.js:270 GET http://localhost/socket.io/?EIO=3&transport=polling&t=Mv0tQCC&sid=LnzFU8ClZrY0NHK5AA-r 400(错误请求)
polling-xhr.js:270 POST http://localhost/socket.io/?EIO=3&transport=polling&t=Mv0tQC-&sid=LnzFU8ClZrY0NHK5AA-r 400(错误请求)