AragornSG AragornSG - 1 year ago 203
C# Question

Unity 3D c# yield return www hangs on particular URL

I'm building a strategy game in Unity, which communicates with server using HTTP, retrieving JSON objects via WWW requests. So far it has been working properly, however recently I've added a tester who is experiencing a strange problem. One of the URLs called by the registration process is hanging at the IEnumerator's "yield return www". The user tried two different machines and two different Internet providers, which suggests it's not environmental problem.

Here is the IEnumerator code:

IEnumerator WaitForRequest(WWW www)
addLogEntry("IEnumerator: "+www.url);
yield return www;

if (www.error == null)
addLogEntry("IEnumerator: " + www.url+" no error");
// do stuff
addLogEntry("IEnumerator: " + www.url + " " + www.error);
Debug.Log("WWW Error: " + www.error);

The url returns the same value for all users and only one has this issue. There are no errors server side, there are no connectivity issues, since all other urls work fast on the same machine & client.

Does anyone know what could cause this behavior?

Answer Source

Once i also encountered the same issue. At that time, the issue was that one URL was taking too much time in giving response. By the logic of my code, the GameObject on which monobehavior was attached and coorutine was running got disabled, causing the game object with the coroutine to die. I thought i should share the issue I had.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download