以下这些问题仅在跨域时才遇到
使用flashsocket,报错:
make sure the server is running and Flash socket policy file is correctly placed
解决方案,增加policyServer.js
var net = require('net');
var fs = require('fs');
// read crossdomain.xml file
var xmlFile = fs.readFileSync(__dirname +'/crossdomain.xml', 'utf8');
// this server runs on 843
var application = net.createServer(function(socket) {
socket.setEncoding('utf8');
socket.on('data', function(data) {
try{
socket.end(xmlFile, 'utf8');
}catch(e){
}
});
socket.on('end', function() {
socket.end();
});
socket.on('error', function(err) {
if (socket) {
socket.end();
socket.destroy();
}
});
}).listen(843);
crossdomain.xml
<?xml version="1.0" ?>
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" to-ports="*" secure="false"/>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
xhr-polling不支持cluster
使用Socket.io 在跨域时遇到的坑
猜你喜欢
转载自freeman983.iteye.com/blog/1969646
今日推荐
周排行