socket and crossdomain problem (Security.PrefetchSocketPolicy )

In testing, i got a error about corssdomain.

**If each server’s ip address is different…

If i call ‘Security.PrefetchSocketPolicy’, webplayer talk to me…
**
** SecurityException: Unable to connect, as no valid crossdomain policy was found **

my crossdomain policy …

<cross-domain-policy> <allow-access-from domain="*" to-ports="*"/> </cross-domain-policy>

I made ‘socket server’ as follows… (client unity is webplayer version)

  1. Policy-server : If unity API call policy, will send crossdomain plicy.

  2. Login-server : check users login

  3. Lobby-server : make room, play game

  • TEST 1
  1. All servers located on same IP address (111.111.111.111)

  2. load unity webplayer

  3. API call ‘Security.PrefetchSocketPolicy( 111.111.111.111, port)’ to connect Login-server

  4. Policy-server send policy packet.

  5. connect Login-server and then… check login

  6. And then… move Lobby-server

  7. API call ‘Security.PrefetchSocketPolicy( 111.111.111.111, port)’ to connect Lobby-server

  8. Policy-server send policy packet.

  9. connect Lobby-server and then… make room and play.

  • TEST 2
  1. It is same test flow. but server’s IP address is different.

  2. ‘Policy-server’ + ‘Login-server’ locate on 111.111.111.111

  3. ‘Policy-server’ + ‘Lobby-server’ locate on 111.111.111.222

  4. " load webplayer → Policy-server → Login-server " is success.

  5. and then IP is change 111.111.111.111 → 111.111.111.222

  6. policy-server-> Lobby-server is fail.

“SecurityException: Unable to connect, as no valid crossdomain policy was found”

**“TEST-1” is success. (no problem)

“TEST-2” is fail.**

I have a question.

If server’s IP is different, what can adjust crossdomain policy ?

Thank you for read my question :slight_smile:

I’m a bit confused by your explanations. If you have two different servers behind two different IPs and you want to connect to them, each server have to provide a cross-domain-policy. Are you sure that both servers provide the policy?

You only need to call Security.PrefetchSocketPolicy when you want to use a different port (not 843) for the policy check, otherwise Unity is fetching the policy automatically from the requested IP at port 843.

Also keep in mind that TCP connections need to check the policy only once. UDP will check the policy every packet that is send since it’s connection-less. Using udp sockets in the webplayer is not really recommended :wink:

http://unity3d.com/support/documentation/Manual/Security%20Sandbox.html