3

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

When the Flash client (built by another team) tries to connect to the server, it's getting a security sandbox violation. I'm aware this has to do with the policy file serving from the Socket.IO server, but I'm at a loss as to exactly how to serve up this file. When I telnet 127.0.0.1 10843 or telnet 127.0.0.1 843 I get no response. If I recall, in past projects we've been able telnet to the policy file server to get the response. This would be ideal to help me verify that it's being served.

I understand that the default port is 10843, and have also tried setting to 843.

Here's what I have:

  • Push service running on localhost:3000
  • Browser clients can connect and join channels no problem
  • I have a crossdomain.xml file in root directory (not sure if this is needed or not)

I have the following settings pertaining to the policy file:

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

An aside (maybe), with these settings I'm also getting an error on starting the service (though 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 not a duplicate; I searched high and low and believe I'm missing something minor. Any recommendations?

trnelson
  • 2,715
  • 2
  • 24
  • 40
  • Try [FlashSocket.io](https://github.com/simb/FlashSocket.IO). I've not used it but it looks like what you would need since flash is not supported since 1.0 was released. I've updated my answer to reflect this. – enolam Nov 21 '14 at 18:28

2 Answers2

2

It seems that Socket.IO developers decided to get rid of some transports, and thus since 1.0 there is no Flash transport support. This is a bit confusing because on the new docs there is simply no mentioning of Flash transport presence at all.

In Socket.IO 0.9 you could find WebSocketMain.swf and WebSocketMainInsecure.swf files somewhere inside socket.io folder. In 1.* there are no any files with .swf extension.

So if you need Flash support you should install Socket.IO 0.9 with this command:

npm install socket.io@0.9
Oleg
  • 22,300
  • 9
  • 68
  • 84
  • So I'm not sure I understand. They outright dropped Flash support across the board? As in no way to support a Flash client at all? – trnelson Nov 21 '14 at 16:15
  • 1
    @trnelson Yes, there are no official confirmation about it, but exploring Socket.IO 1.* source code tells that this is true. But you can install 0.9 with Flash transport support. – Oleg Nov 21 '14 at 16:43
  • Sorry to belabor the issue, but is it possible to still use Flash with Socket.IO if I can handle serving a policy file? I'm not too familiar with the exact specifics, but it seems like this might be the case. Any ideas? – trnelson Nov 24 '14 at 02:21
  • @trnelson It might be possible. But you will have to study [Socket.IO protocol](https://github.com/automattic/socket.io-protocol) to make your own client on Flash. There are a lot of third party clients written in Java, Obj-C, C#, etc. So if it is possible with abovementioned languages, it should be possible with Flash, if you can serve a policy file. – Oleg Nov 24 '14 at 08:10
0

According to the socket.io documentation, the flash policy server defaults to true when the flashsocket transport is enabled. This means that the flashPolicyServer (which should be flash policy server) option is unnecessary. Try setting the port before setting the transports as well... like this.

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

This ensures that when the flash socket server starts up, it starts with that port, rather than starting, getting killed and then restarted with the new port. Also, since 843 is a root port, make sure it has permission to use that port.

edit It seems as though socket.io dropped support for flash outright. The docs on their github are for 0.9.0. Which is confusing. There is an alternative that might be useful although I have not tried it. FlashSocket.io should help facilitate your needs.

enolam
  • 221
  • 1
  • 6
  • Tried all of these suggestions and no luck. I ran cmd as administrator to start the Node service, rearranged the lines as you suggested (and also tried removing port 843 to default to 10843). Still no luck. Am I missing an NPM package or something? Even with the 'flash policy port' option I was still getting the error `Option flash policy port is not valid. Please refer to the README.` – trnelson Nov 21 '14 at 12:08
  • I know that things changed with 1.0 but if they changed the flash policy server, it wasn't documented. – enolam Nov 21 '14 at 12:12
  • Hmm, per the package.json file in the modules folder, I have version 1.1.0. It doesn't seem like the policy file requires additional packages to work. Am I correct in that understanding? – trnelson Nov 21 '14 at 12:53
  • That's correct as far as I understand. Can you try .9 and see what happens? – enolam Nov 21 '14 at 13:15
  • You could also just run a separate server on that port to serve the policy as well. Might be less trouble – enolam Nov 21 '14 at 13:20
  • Do you happen to know if the Flash client will actually still *work* with the socket server (given that I could find a way to provide the policy file?) Or is support for it completely gone? – trnelson Nov 21 '14 at 21:56