Skip to content
This repository

Alternate Flash Policy Port - needs documenting #1011

Open
ADumaine opened this Issue August 30, 2012 · 0 comments

1 participant

Allan Dumaine
Allan Dumaine

Lots of searching through docs and web to find how to configure this with not much success, so here is one solution.

Needed to change the flash policy port from the default 10843 (issues with ISP opening ports). I found information on how to run on another port for the server but still kept getting SecurityError on the client.

In this example the node server is running with SSL and is only used for socket.io communication (not feeding up any HTML). The flash policy port has been reconfigured to also listen on port 3300

SERVER

var fs = require('fs');

var options = {
  key: fs.readFileSync('/etc/ssl/ebscerts/wildcard.my_example.com.no_pass.key'),
  cert: fs.readFileSync('/etc/ssl/ebscerts/wildcard.my_example.com.crt'),
  ca: fs.readFileSync('/etc/ssl/ebscerts/bundle.crt')
};

var app = require('https').createServer(options, handler)
  , io = require('socket.io').listen(app);

app.listen(3300);

//for testing
function handler (req, res) {
      res.writeHead(200);
    res.end("welcome to ebidnsave\n");
}

//production settings
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', 1);                              // reduce logging
//io.set('match origin protocol', 'true');
io.set('flash policy port', 3300);       //override policy port  
io.set('transports', [                     // enable all transports (optional if you want flashsocket)
    'websocket'
  , 'flashsocket'
  , 'htmlfile'
  , 'xhr-polling'
  , 'jsonp-polling'
]);

Finally realized the client also has to be overridden. This can be done by passing the 'flash policy port' on the io.connect call.

CLIENT

   //socketAddr is server uri  ex. https://ww2.my_example.com:3300
   var socket = io.connect(socketAddr,{'flash policy port':3300});
   socket.on('connect', function () { .....

The above works with IE9 (seems to work with IE8 with a quick test). BUT there is still a delay in setting up the socket which I think is due to flashsocket trying port 843 first.

Socket.io.client documentation lists some of the options that can be configured but does not mention 'flash policy port'.
In digging through the file I found on line 1512 of 0.9.10 this list of options that if passed are merged in and override defaults. Not recommending others be changed.

 function Socket (options) {
    this.options = {
        port: 80
      , secure: false
      , document: 'document' in global ? document : false
      , resource: 'socket.io'
      , transports: io.transports
      , 'connect timeout': 10000
      , 'try multiple transports': true
      , 'reconnect': true
      , 'reconnection delay': 500
      , 'reconnection limit': Infinity
      , 'reopen delay': 3000
      , 'max reconnection attempts': 10
      , 'sync disconnect on unload': false
      , 'auto connect': true
      , 'flash policy port': 10843
      , 'manualFlush': false
    };

    io.util.merge(this.options, options);

It would be nice if this could be added to both socket.io and socket.io.client documentation. Hopes this helps...

Muaz Khan muaz-khan referenced this issue in muaz-khan/WebRTC-Experiment July 13, 2013
Closed

SSL (HTTPS Socket.io) #62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.