Unity Community


Results 1 to 10 of 10

  1. Posts
    13

    How to use the Security.PrefetchSocketPolicy !!!!

    I am confused with Security.PrefetchSocketPolicy call. Headachy some really!!

    1. Only the Web Player is Evil some:
    I use the photon as my game server which has its policy server on default port 843.
    Then I connect to the server(use socket, you known). Everything works properly in Editor and StandAlone but the WebPlayer.
    2. The IP and Port is OK
    I am sure my fireworks not block the port 843, I turn them off. I can telnet the port and get the crossdomain string back successfully. either to the sockpol Server(offer by unity) or Photon policy server. All port and IP works perfectly except in Webplayer!
    3.I do myself, but not work
    The doucument from the Unity tell me I needn't call the Security.PrefetchSocketPolicy("172.16.0.111", 843, 300), eveything default will work for me. But in act it doesn't.
    OK, no problem, I did it myself with the following code:
    void Awake()
    {
    if (Global.Instance && !Global.Instance.Offline)
    {
    PhotonNetwork.Init();
    Debug.Log("fffffffffffffffffffffffffffffffffffffff ffffff1");
    if (!Security.PrefetchSocketPolicy("172.16.0.111", 843, 300))
    {
    Debug.LogError("PrefetchSocketPolicy failed!");
    }
    else
    {
    Debug.LogError("PrefetchSocketPolicy OK!");
    }
    Debug.Log("fffffffffffffffffffffffffffffffffffffff ffffff2");
    PhotonNetwork.ConnectUsingSettings("0.1");
    }
    }
    4. I try to change the port to 2018, this time is more strange, It doesn't work even in Editor
    I change code to: if (!Security.PrefetchSocketPolicy("172.16.0.111", 2018, 300)) and change the photon policy listener port to 2018

    I mean if I can call Security.PrefetchSocketPolicy("172.16.0.111", 843, 300) successfully, everything will be ok! But I never, never got the successful return. It is always print "PrefetchSocketPolicy failed!"

    Pool man, I've work around it for 5 days, I test it , I try all suggestion from the warmhearted friends (etc: Tobias,). but it still stay there. The evil webplayer!!!!
    Help me Pls. guy?
    How can I me the Security.PrefetchSocketPolicy work in webplayer???????


  2. Posts
    63
    What's the third parameter? I use this when I hit ElectroServer and it works just fine, although I never examine the value it returns:
    Code:  
    1.                #if UNITY_WEBPLAYER
    2.                 Security.PrefetchSocketPolicy(ip, Convert.ToInt32(serverPort));
    3.                 #endif

    Perhaps the problem is with your crossdomain? What are you delivering?
    Teresa Carrigan
    Senior Engineer
    Electrotank


  3. Posts
    13
    Quote Originally Posted by tcarr9 View Post
    What's the third parameter? I use this when I hit ElectroServer and it works just fine, although I never examine the value it returns:
    The third parameter is timeout is ms. I pass it as 300, 5000 or don't pass anything just like you. They don't work too.

    Quote Originally Posted by tcarr9 View Post
    Perhaps the problem is with your crossdomain? What are you delivering?
    crossdomain string is OK, because I never change it. I am sure the policy request is not send or blocked. Because I debug the policy server, the server can't receive the request. When I connect use telnet IP 843 or run my game in Editor, the server can receive the request.

    But in webplayer, It won't send even if I add the code such as : Security.PrefetchSocketPolicy(ip, Convert.ToInt32(serverPort));
    Why!!!!!!!!!!!!!!!!!



  4. Posts
    13
    Quote Originally Posted by tomoprime View Post
    I wrote a post that may help you.
    Yeah, I have read you post for 4 times. But it all about policy request failed in Editor. But my state is : Everything works properly but web player!
    Only the web player.
    I try use the default port 843 or custom port:2048. Both failed!!


  5. Posts
    13
    Help me pls! Am I the only one met such a problem????
    Maybe I don't explain my problem clear. So I attach my link about the same problem here:
    http://forum.exitgames.com/viewtopic...7&p=8458#p8458

    You know, I am really need you help now. For my game could publish to the tester, just for this evil problem!!!!!!


  6. Posts
    13
    Nobody can help me??????????


  7. Location
    NY
    Posts
    211
    Hi josszp

    Of course it would fail for your Web Player. The whole point of having the secure socket policy server is to prevent WEB PLAYER clients from accessing sites that shouldn't be accessible by users outside their intranet. So the cross domain files says I will allow this address on this port to be accessed by the web player. The Policy Server should run on the same box (same address) of the Game Server that is doing the hosting. The web player expects the policy server to be running on port 843. Unix machines would give you grief about reserved ports lower than 1024 as this needs to be run as root (not a problem for Windows). So Security.PrefetchSocketPolicy allows you to change the default setting to something higher than 1024 like 2048. But your photon policy server needs to actually run on 2048 or whatever secure socket policy server you have in place (like secpol.cs). The cross domain file would then name the actual game server port / range for connecting to your game server. Your game server port would not run on 2048 which is being occupied by the policy server...

    You may face another problem... Your Server Name look up may return more than one ip addresses. This code gets around that issue.
    Code:  
    1.     public string ipAddress = "www.mycomputer.com"; //"localhost";
    2.     public int gamePort = 14248;
    3.     public int policyPort = 8843;
    4.  
    5. public void OnGUI()
    6.     {
    7.         GUI.Label(new Rect(30, 255, 230, 40), "Server\nIP Address: ");
    8.  
    9.         ipAddress = GUI.TextField(new Rect(110, 270, 170, 22), ipAddress);
    10.  
    11.         if (GUI.Button(new Rect(20, 300, 260, 30), "Play Multi Player"))
    12.         {
    13.            
    14. # if UNITY_WEBPLAYER
    15.             bool isPolicyConnected = false;
    16.             string hostname = gm.ipAddress;
    17.             IPAddress[] ips = Dns.GetHostAddresses(ipAddress);
    18.             foreach (IPAddress ip in ips)
    19.             {
    20.                 ipAddress = ip.ToString();
    21.                 if (!(isPolicyConnected=Security.PrefetchSocketPolicy(ipAddress, policyPort, 5000)))
    22.                     print("policy socket address failed to connect to "+ipAddress+":"+policyPort);
    23.                 else break;
    24.             }
    25.             if(isPolicyConnected)
    26.                 Application.LoadLevel("mainscene");
    27.             else ipAddress=hostname;
    28. # else
    29.             Application.LoadLevel("mainscene");
    30. #endif
    31.         }
    32. }


  8. Posts
    13
    God save me! Yeah!!!
    I am so excited, almost bacchanal some!! Just for getting rid of the Web player policy EVIL. Good bye, Mr Evil!!! Aha!
    So I am here, to tell the solution for the pool guy meets the same evil like me. I trace it for two weeks long. I means it is a period of hard time. It shouldn't be headache to you guys any more.
    Very simple reason. In my scene there is dlls (I18N.dll, I18N.CLK.dll), these two dll is used to support the Simple Chinese Input in Unity version 2.6(in version3.0 up, we needn't them. ). the version of them is older some. They cause some crash we can't print, but they make my browser cant parse the policy request. So the on the server side, policy server never gets any request.
    That's it!
    Evil's gone!!! The god sun's up!!!
    Thanks for the guys reply the post!!!


  9. Posts
    267
    Quote Originally Posted by josszp View Post
    God save me! Yeah!!!
    I am so excited, almost bacchanal some!! Just for getting rid of the Web player policy EVIL. Good bye, Mr Evil!!! Aha!
    So I am here, to tell the solution for the pool guy meets the same evil like me. I trace it for two weeks long. I means it is a period of hard time. It shouldn't be headache to you guys any more.
    Very simple reason. In my scene there is dlls (I18N.dll, I18N.CLK.dll), these two dll is used to support the Simple Chinese Input in Unity version 2.6(in version3.0 up, we needn't them. ). the version of them is older some. They cause some crash we can't print, but they make my browser cant parse the policy request. So the on the server side, policy server never gets any request.
    That's it!
    Evil's gone!!! The god sun's up!!!
    Thanks for the guys reply the post!!!
    SO what did you do to fix the problem?? Where do I stick these missing libs so the web player can use them?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •