[url]WWW.isDone[/url] never true when in editor

I’ve got this problem when making web requests using the WWW class. The problem apears only when played in Unity editor (IDE) - in browser applet everything works as expected.

I also noticed that on the first run after rebuild this happens all of the time, and on the second run it sometimes works.

It became very important to me now since I’m doing some editor stuff.

What is going on here?

Thanks in advance.

Furthermore, even in browser app, I noticed that simultanious calls to the same server-side URL result in “mixing-up” responses.

For instance, if I call the same HTML page using the two (simultanious) web requests using the WWW class, I get back both responses, but sometimes one has blank response, and the other contains both (appended together).

???

Thanks.

I can’t speak about your second problem, but for me my game makes WWW calls fine from the editor.

How are you checking IsDone? During the Update() calls each frame?

Yap, I’m checking isDone during the Update calls.

btw I don’t like to use yields (it even didn’t work when I tried it)

Yeah, I don’t touch Yields either; seems like too much trickery to me.

My only thought is to start a new project that’s completely empty and do some WWW tests with it to make sure it’s not something else in your scene. And try to make WWW calls to other websites or domains to make sure it’s not an issue there.

If the problem still persists with the simple test, try posting the code and we can take a look at it?

Ugh, the code is pretty complex, meaning I have a wrapper class which handles making WWW requests (puts them in queue, processes them and triggers responder delegates). Internally, it does all this things in Update() method.

I agree, I should make the least complex case of it and then post it here.

Anyway, thanks for help!:slight_smile:

Update:

I have a problem with requests which get no response. Is there anything on my PC that can (in randomly fashion) stand on the way of Unity ↔ server communication. What should I check (logs etc.)?

Update 2:

I found a major flaw in my design: I have been using a collection List<WWW> _queue = new List<WWW>(); and have been putting WWW instances into this collection. The behaviour I wanted to accomplish is queuing - to start requests one by one (start the next one after the previous is finished) even if added to queue at the same time. However, I forgot that the moment you instantiate WWW using the new operator, the web request is send. So, my queueing mechanism didn’t work by design.

Then I refactored the whole thing; I created my custom WebRequest class:

public class WebRequest
{
    public string Url;
    public Hashtable Headers;
    public byte[] PostData;
    public WWWForm Form;
}

This is the type of request that now I put in queue. The WWW is not instantiated before the request gets out of the queue.

Now:

  1. This change get me rid of one problem: mixing response data (WWW.data[/url] which is a string). I don’t know exactly why, but now I don’t have occurances of one blank response and other response with two datas apended together. I’ll be glad if anyone founds out the reason :wink:

  2. The other problem continued appearing (the WWW is never done, meaning the response never gets back to Unity IDE). However, I noticed that it happens only when calling a localhost! As I published the server-side (ASP.NET app) to other machine (server), everything started to work properly.

Seems that those problems were somehow interconnected, so I couldn’t figure out the second one without solving the first. I will test it further, hoping that it won’t start happening again. :slight_smile:

Interesting stuff. I implemented a similar queuing system (but a more specific method instead of a general WWW wrapper) and haven’t had issues thus far. Though, all my calls so far have been to an external server; haven’t bothered testing on my own local machine.

If it’s failing on localhost, maybe antivirus or (heaven forbid) firewall software is interfering. Can you check your own localhost server access logs?

Perhaps there’s an issue with Unity accessing localhost in general? Maybe try setting up your test server to respond to 127.0.0.1, or setup an entry in your Windows hosts file to redirect?

I’ll definitelly try it. Thanks!