views:

312

answers:

3

Hi,

I have a Flex client using a Flash binary (TCP) socket for communication with a Java server. I have a localhost (Apache) server providing a crossdomain.xml file which is wide open just while I am testing.

My code successfully loads the policy file on startup.

I then connect the socket to the server without any difficulty and send a message and get a response. All good so far.

However, when I send a second message through the same socket I get a pause of about 12 seconds then a sandbox violation error:

Security Error: Error #2048: Security sandbox violation: file:///C:/apache_root/ttt1/ttt1.swf cannot load data from localhost:45455.

This is the same port and socket through which the first message succeeded.

I tried re-loading the policy file before every send, but I get the same result.

Any idea why this might be happening? I clearly have an open socket at one point. I am flushing the socket after each send and I tried doing that after each read as well, but the same result.

Thanks in advance

EDIT:
If I recreate the socket prior to every call my code works. I am struggling to believe that this is correct, but maybe there is a Socket setting I am missing.

A: 

I think it depends on the sandbox-policy you used in the compilation process of your swf not on your crossdomain.xml... maybe this docu helps you:Security sandboxes

But I'm not 100% sure

Jochen Hilgers
do you happen to know how to change the sandbox setting in Flex 3?
Simon
it's the use-network compiler flag: http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_14.html
Jochen Hilgers
I have no explicit compiler setting, which means it will take the default of "true" and that means I can get at network resources. I think this is a red herring. If it were an issue with the compilation flags it would not work at all, rather than work only once.
Simon
you're right...
Jochen Hilgers
A: 

I recently spent quite a bit of time dealing both with socket policy files and crossdomain policy files. Please post both of your policy files so I can have a bit more information to help.

Murf
Much more information, plus the socket policy file and a bounnty here... http://stackoverflow.com/questions/1709467/why-does-the-flash-player-throw-a-sandbox-error-in-this-case/ I don't have a crossdomain.xml file as I am not using HTTP.
Simon
A: 

This sort of sounds like a cache problem. Perhaps you're pulling the first socket connection out of cache and the second one gets rejected because it's getting a 200 from the server.

You might want to add localhost to your flash security exceptions list for debugging. that will quiet the sandbox errors until you get your piece to it's production environment.

Aaron Lampros