Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternate Flash Policy Port - needs documenting #1011

Closed
ADumaine opened this issue Aug 30, 2012 · 1 comment
Closed

Alternate Flash Policy Port - needs documenting #1011

ADumaine opened this issue Aug 30, 2012 · 1 comment

Comments

@ADumaine
Copy link

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...

@arivasvera
Copy link

Hi @ADumaine, I followed the steps you suggest but the browser warns me of the following:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://domain.dev:3300/socket.io/1/?t=1422538971224. This can be fixed by moving the resource to the same domain or enabling CORS.

May you help me?

I tried with 3300 and 3006 ports

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@ADumaine @arivasvera and others