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

Proxy flash socket policy requests #224

Closed
robertothais opened this issue Apr 3, 2012 · 8 comments
Closed

Proxy flash socket policy requests #224

robertothais opened this issue Apr 3, 2012 · 8 comments

Comments

@robertothais
Copy link

Some libraries such as socket.io can fall back Flash based sockets when the client does not support WebSockets. To achieve this, the client's Flash program first needs to request a 'socket policy file' from the server. This request consists of a self-closing XML node followed by the null byte sent over raw TCP:

<policy-file-request/>\0

node-http-proxy will drop this request, causing the Flash socket connection to fail.

@coderarity
Copy link
Contributor

Just run this wonderful thing here on your proxy server! Pretty much, it looks like this:

var pf = require('policyfile');
pf.createServer().listen();

And then all of your problems should be solved, almost like magic. (Socket.io uses this library for it's Flash Policy File Server as well)

@cronopio
Copy link
Contributor

@rthais Works this lib for you?

@rthais @coderarity can we close this?

@robertothais
Copy link
Author

Yes, that works. I think we can close this issue.

@konklone
Copy link

For anyone visiting this thread later with the same question - the code that worked for me is:

var pf = require('policyfile');
pf.createServer().listen(null,server);

where server is the server you already created via http.createServer().

@heygambo
Copy link

heygambo commented Apr 2, 2013

does this work today?

There is a problem with non 80 ports on nodejitsu right?
https://www.nodejitsu.com/documentation/a-quickstart/faq/#how-can-i-make-my-app-use-a-port-other-than-port-80

Is there any chance to have it running on nodejitsu?

@dvideby0
Copy link

@konklone I followed your instructions for policyfile but I get an error that the address is in use. I have been going in circles with this for a bit. Any help would be greatly appreaciated

var express = require('express');
var app = express();
var server = require('http').createServer(app).listen(process.env.PORT || 9009);
app.use(express.static(__dirname + '/public'));
var pf = require('policyfile').createServer().listen(null, server);
var io = require('socket.io')({
  transports: ['websocket']
}).listen(server);

@konklone
Copy link

@dvideby0 It sounds like you might already have an instance of the server running in some other terminal?

@dvideby0
Copy link

@konklone Unfortunately no and the code I put above fails all on its own (without any other logic). Not sure if there is something additional I am supposed to add but I should probably point this issue to the author. Thank you for the help sir!

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

6 participants