- Home /
SocketPolicyServer Issues
Everyone,
We are having issues with the SocketPolicyServer when trying to use the WebPlayer.
Our app is using async .NET sockets to connect to a small server application that can run either locally, or remotely.
The sockets connection and stream work correctly of course in standalone MAC or PC mode, and EVEN work in the editor when the active build is set to WebPlayer. But, the app does not working correctly when played in the actual webplayer.
To verify that the policy server is running and providing the correct policy file we are manually checking OnApplication.webSecurityEnabled and calling Security.PrefetchSocketPolicy prior to connecting the socket, and all is well!
We are stumped.. What magic incantation do we need to get this work?
Does anyone have an example of .NET sockets and the policy server working in a webplayer?
Also, is there some more details regarding the policy when using .NET sockets?
We are pretty sure that it is NOT a policy server problem since we have actually the same results with our server app or with Sockpol.exe.
Actually we just integrated the SockPol.cs code into our VS2010 server app, so are confident the response is well formed.
At the moment we think that there is either a bug in the Webplayer, or some missing notation required in the policy response that is not well-documented.
Thanks in advance for any help or information.
Aiken Dev/AikenLabs
Answer by soonts · Mar 21, 2011 at 12:26 PM
Are you trying to run the server locally? I did and failed: no matter what, unity complained about the missing policy.
After I moved the server to another machine, everything worked OK.
I suspect damn web player intentionally blocks socket communications with the localhost.
Answer by hazmat · Oct 16, 2012 at 09:26 PM
The webplayer does not block socket communications with localhost. I've noticed some oddities with Security.PrefetchSocketPolicy(host,port). Another thing to check is to make sure the SockPol server is listening to the right protocol (IPv4, IPv6, or both/wildcard). If you have an IPv6 enabled windows machine 'localhost' can get the IPv6 address before the IPv4 and the SockPol may only be listening to the IPv4 address (127.0.0.1). Possible solutions: 1: explicitly call out 127.0.0.1 2: make sure sockpol listens to IPv4 and IPv6 3: Use the Socket.Connect(EndPoint) method which generally bypasses the unity webplayer security sandbox -- I've used this w/o needing to fetch a security policy. 4: Create a java applet which runs a sockpol server on a high port, embed it in your webpage and fetch socket policy from it.
Your answer
![](https://koobas.hobune.stream/wayback/20220613091545im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Web Player connection issue. 0 Answers
Security.PrefetchSocketPolicy problem. 0 Answers
TCPClient and SslStreams in WebPlayer (C#) 0 Answers
How connect from Unity WebPlayer app to C# server 1 Answer
Socket IO server 1 Answer