How to serve policy file from Socket.IO/Node.js

I created a Socket.IO server that pushes the listing information to linked clients. Over HTTP in the browser, everything works as intended with web sockets, however one of the client types that will consume the service is strictly flash (not flushing the socket, just up Flash). We are using AS3 Web Socket Client library .

When a Flash client (created by another command) tries to connect to the server, it gets a sandboxed security violation. I know it has to do with the policy file serving the Socket.IO server, but I don't understand how exactly to serve this file. When I am telnet 127.0.0.1 10843

or telnet 127.0.0.1 843

, I do not get an answer. If I remember, in past projects we got telnet to the policy file server to get a response. It would be perfect to help me verify that it is being served.

I understand the default port is 10843 and also tried to set it to 843.

Here's what I have:

  • Push service running on localhost: 3000
  • Browser clients can connect and connect to channels without issue.
  • I have a crossdomain.xml file in the root directory (not sure if this is necessary or not)

I have the following options related to the policy file:

// Socket Setup
io.set('transports', ['websocket','flashsocket']);
io.set('flashPolicyServer', true);
io.set('flash policy port', 843);

      

As an aside (maybe) with these settings, I also get an error when starting the service (although it still starts):

Option flashPolicyServer is not valid. Please refer to the README. 
Option flash policy port is not valid. Please refer to the README.

      

I'm at a loss. Hopefully this is not a duplicate; I have searched high and low and find that I am missing something secondary. Any recommendations?

+3


source to share


2 answers


It looks like the Socket.IO developers decided to get rid of some transports, and thus 1.0

there is no support for Flash transport. This is a little confusing because there is no mention of the Flash transport at all in the new docs.

In Socket.IO, 0.9

you can find files WebSocketMain.swf

and WebSocketMainInsecure.swf

somewhere inside the socket.io folder. There 1.*

are no files with the extension .swf

.



So, if you need Flash support, you have to install Socket.IO 0.9

using this command:

npm install socket.io@0.9

      

+2


source


According to the socket.io documentation , flash policy server

the default is used true

when flashsocket transport is enabled. This means that the option flashPolicyServer

(which should be flash policy server

) is unnecessary. Try setting the port before setting up transports ... like this.

io.set('flash policy port', 843);
io.set('transports', [ 'websocket', 'flashsocket' ])

      



This will ensure that when the flash socket server starts up, it will start at that port rather than start, get killed, and then restart with a new port. Also, since 843 is the root port, make sure it has permission to use that port.

edit It seems that socket.io has dropped support for flash. Docs on their github for 0.9.0. This is confusing. There is an alternative that might be helpful, although I haven't tried it. FlashSocket.io should help you with your needs.

0


source







All Articles