- Home /
Webplayer throwing FTP errors as popups
I'm using the WWW class to grab imagery from an ftp server. The ftp server limits the downloads to 5 simultaneously. When I kick off a bunch of requests I handle this gracefully: I have a loop that checks the www progress of each download, and when it detects a 421 error (too many connections) it stops the download, disposes the WWW call, and adds the download to a queue to be restarted when another download finishes. I also catch permanent errors (e.g. file not found) and handle those gracefully.
All of this works perfectly in standalone versions, tested on both Windows and Mac. However, in the webplayer, every time the WWW encounters an ftp error it seems to immediately return it to the browser, which then sends a popup error to the user. The popup is in the following format ([Title:] indicates what's in the popup titlebar). Each one has a yellow warning icon next to the text.
[Title:]Alert
421 There are too many connections from your internet address.
[Title:]Alert
550 Failed to change directory.
[Title:]Alert
425 failed to establish connection
Since I might kick of 15 of these at a time, I end up spamming the user with 10 popups. Clearly not acceptable.
Any idea how to prevent Unity from sending these to the browser? This is a serious WTF error - why would Unity, a game engine, ever throw an error like this to the browser even if I weren't handling things gracefully?
BTW: If you want to test this, just set up a WWW call with a bad address, e.g. ftp://thisisabadaddress
Then, I have a loop set up like this:
private IEnumerator monitorDownload()
{
while (state == State.Downloading)
{
if (www.isDone)
{
if (www.error != null)
{
Debug.Log("Could not download texture from " + url + ": " + www.error);
if (www.error.Contains("421"))
{
state = State.Queued;
Debug.Log("FTP server rejected download (" + url + "), adding to queue.");
www.Dispose();
}
else //died with fatal error
{
downloadFinished(false);
}
}
else //download succeeded
{
downloadFinished(true);
}
//close the thread
yield break;
}
else //downloading
{
}
yield return new WaitForEndOfFrame();
}
}
Answer by Bunny83 · Nov 11, 2011 at 11:23 PM
Well, as far as i know the www calls work a lot different in the webplayer. Unity does those requests via the browser and doesn't do the connection itself. I guess it completely depends on the browser you use if such a warning is displayed or not.
So i guess it's actually the other way round: Not Unity passes the error to the browser, the browser passes the result to unity so i guess there's not really a way to prevent the browser from doing that when using the WWW component.
It still should be possible to use .NET / Mono to establish the connection and handle the download yourself. Make sure you read the Security Sandbox documentation carefully when you want to try that.
Thanks Bunny, that really clears things up for me. I'll poke around the documentation, and if we come up with anything clever I'll try to post it to the forums.
Your answer
Follow this Question
Related Questions
How do I properly send binary data (byte[]) to a MySQL database? 4 Answers
Having Trouble with Javascript GET and URL 1 Answer
Failed downloading http with WWW on Internet Explorer 0 Answers
Bytes array always empty in WWW object (on WebPlayer) 0 Answers
webplayer www sendmessage to loadExternalImage with parameter (url) 1 Answer