Unity3d WWW and network connection errors

I am trying to handle missing network connections, when loading external data in Unity3d.

My application pulls a lot of data from a server, and without a netconnection the application should fail, communicating the problem to the user.

I use the WWW class for all data retrieval, and would like to handle loss of network connection using WWW as well.

My main problem is that the error property of the WWW class returns:

"Rejected because no crossdomain.xml policy file was found"

When I pull my network cable from my computer.

I can't figure out how to distinguish a missing network connection from a missing crossdomain.xml file, which I want, since they are entirely different problems.

I don't want to "interpret" all "crossdomain policy errors" as network losses, because they may not be.

My code for loading data looks like this:

public class SendAndLoadData : MonoBehaviour
        public delegate void SuccessEventHandler(string data);
        public delegate void ErrorEventHandler(string msg);

        public void SendData(string url, SuccessEventHandler onSuccess, ErrorEventHandler onError) {

        IEnumerator LoadRemoteData(string path, SuccessEventHandler onSuccess, ErrorEventHandler onError)
            var _www = new WWW(path);
            yield return _www;
            if (_www.error != null)
                if ( onError != null ) {
                var data = _www.text;
                if ( onSuccess != null ) {


Any suggestions would be appreciated.


Unless for some reason you are testing your code in using a Webplayer build you should get the error message "Recv failure: Connection was reset" in the event of a dropped/failed connection to the server.

When using a web player build (which I am assuming you are) you SHOULD treat all "Rejected because no crossdomain.xml policy file was found" as network losses because they all SHOULD be caused by dropped/failed connections.

This is due to the fact that these two scenarios cause this error: Dropping a connection to a server whilst trying to download crossdomains file(I'm assuming this is a cause in webpayer as I currently have no time to test this fact), or the server the client is attempting to contact does not have a crossdomain.xml file. Due the security measures in the Unity Web Player any connections made from a client must be to a server with a valid crossdomains policy.

The requirement of the policy is an attempt to prevent people making exploits to gain access to internal network resources etc. This may be annoying during testing, but at no point in production should a missing crossdomain policy be an issue. You should only be connecting to your own servers which should have said files correctly set up or other servers which are correctly set up with correct policies.

to check whether your device is connected to a network you can use below code:

if(Application.internetReachability == NetworkReachability.NotReachable)
  //your code

Need Your Help

Why does Interface Builder show hidden views through the views above them?

ios xcode interface-builder

When nesting views in Interface Builder, if I have an opaque view with hidden views beneath it in the view Hierarchy, the hidden views are visible through the higher view and are just partially

How to search something on a complex NSMutableArray

ios nsmutablearray nsmutabledictionary

I have a NSMutableArray. It has 8 objects. Each object has 5 key value pairs like this