Why does the Flash Player throw a sandbox error in this case?

孤街醉人 提交于 2019-11-30 11:22:26

I've been testing this locally and everything seems to be working fine until the socket gets closed. Shouldn't the socket not get closed? After the message is sent to the Flex client, the Java code does:

_in.close();
_out.close();
_socket.close();

Then the Flex client gets the sandbox violation the next time it tries to communicate with the socket. If I create a new socket connection again then send and receive works fine, followed by a close. But after a minute or so I get another sandbox violation. I wonder if Flash is trying to ping the socket and since it's closed it throws the sandbox violation?

Have you tried adding the allow-http-request-headers-from element?

<allow-http-request-headers-from domain="*" headers="*" />

Or specifying the actual ports instead of * for the allow-access-from element?

<allow-access-from domain="*" to-ports="843,45455" />

A similar problem here indicates that localhost was not being resolved to 127.0.0.1.

You might try changing over to the IP address and see if that helps.

You might try a few things further in the code with the Security class in addition to yoru crossdomain.xml

Try:

Security.allowDomain("*")
Security.allowInsecureDomain("*")

Or if you are loading from external servers outside the aporoved allowed host:

Security.allowDomain(loader.contentLoaderInfo.url)

Then slowly turn it back on until you hit the error.

Make sure you can hit the policy file directly and there is no block or other app running on that port. Typically when I run sockets I go higher than 5000 just to make sure nothing is using up the port. Or try a few different ports.

Also just as a simple check make sure you named it crossdomain.xml and it is all lower case. I have had programmers pull their hair out and this turned out to be the cause.

try to put a blank before xml closing tag "/>", just like in dan_nl suggestions, eg:

<allow-access-from domain="*" />

Don't laugh at it, I just solved a problem very similar to yours like this (and it really looks like a parsing bug IMHO)

By any chance... is this occurring on Windows Vista? Is the IP address specified as a host name? If so, see this.

Or maybe it's occurring while the profiler is active? If so, see this.

When sending the policy file, the server should always send a zero byte after policy xml. It is not clear from the description above whether the zero byte is sent, and this may confuse the Flash player eventually.

This may or may not help you but we were having similar issues. We were getting the Security error but it was inconsistent. I built the front end and worked with a developer who was dealing with the Socket written in PHP. The problem seemed to be that there was indeed a race condition where Flash would try to connect to the socket prior to receiving the Policy File. So on the front end I created a re-try in the Security error handler which would run a set number of times before giving up, also set the timeout from the default 20 seconds down to 6 or 8. It would usually catch on the 2nd try and this did help but there were times where it would take 8-10 seconds to connect, not an optimal solution.

Came across a few links in my searches and this one said something about setting up a delay on the server, 7th post down: http://projectdarkstar.com/forum/?action=printpage;topic=1134.0

In the end we downloaded and used the Python policy file server from this Adobe article and it has been working flawlessly, I can't explain why, I'm not a server guy, but it might be worth a shot:

ok, I can only post 1 hyperlink since I'm a new user, strange. Search 'Setting up a socket policy file server' and it should come right up, there are example files in that article on Adobe's site.

I think James Ward is right--I'm working with Sockets now and I ran into this issue the other day. I found a post that suggested that if the Flash client does not close the Socket when the COMPLETE event is dispatched, this can result in the error you're seeing. I've added code to close the client Socket on COMPLETE, and everything is working fine so far.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!