套接字IO和策略文件Internet Explorer

时间:2014-09-04 19:57:43

标签: node.js flash internet-explorer socket.io

我在Internet Explorer上使用Socket.io时遇到问题。 经过几秒钟后,我收到了以下错误消息:

cannot connect to Web Socket server at ws://example.com.br:80/socket.io/... (SecurityError) make sure the server is running and Flash socket policy file is correctly placed.

我做过一些关于什么是政策文件的研究,但其中任何一项都可以帮助我。

有什么想法? 谢谢!

/*** IO ***/
var
  options     = { retry_max_delay: config.app.redis.retryMaxDelay },
  redis       = require('redis'),
  client      = redis.createClient(config.app.redis.port, config.app.redis.host, options),
  Connector   = require('./lib/Connector'),
  Helper      = require('./lib/Helper'),
  io          = require('socket.io').listen(server),
  Social      = require('./lib/service/Social'),
  Terms       = require('./lib/service/Terms'),
  UserChecker = require('./lib/service/UserChecker'),
  users       = {};

io.configure(function() {
  'use strict';

  io.set('browser client gzip'         , false);
  io.set('browser client minification' , false);
  io.set('close timeout'               , 60);
  io.set('heartbeat interval'          , 25);
  io.set('heartbeat timeout'           , 60);
  io.set('log level'                   , config.socket.logLevel);
});

io.set('transports', [
  'websocket',
  'flashsocket',
  'htmlfile',
  'xhr-polling',
  'jsonp-polling'
]);

io.on('connection', function(socket) {
  'use strict';

  logger.debug('Socket (' + socket.id + ') connected.');

  client.incr('chat:connection');

  var
    connector   = new Connector(socket),
    social      = new Social(config),
    terms       = new Terms(config),
    userChecker = new UserChecker(connector, socket);

  function send(response, bind, callback) {
    if (bind) {
      connector.addEventListeners();
    }

    if (callback) {
      callback(response);
    }
  }

  socket.on('join', function(message, callback) {
    var
      json = Helper.toJSON(message),
      skip = userChecker.shouldSkip(json, config);

    if (skip) {
      var data = userChecker.skip(users, json);

      users = data.users;

      return send(data.response, true, callback);
    }

    social.check(json, function(response, access) {
      if (!access) {
        return send(response, false, callback);
      }

      terms.check(json, function(response) {
        send(response, true, callback);
      });
    });
  });

  socket.on('disconnect', function() {
    users = userChecker.disconnect(users);
  });
});

module.exports = app;

0 个答案:

没有答案