WWW form now always returns a 404 error in Unity 2017
The code below works great in previous versions of Unity.
The URL is valid (Browser giving the good page - and not a 404
A lot of people warn me about this (I sell an asset on the store) so it’s not just on my side
Unity 2017 is authorized through the firewall
If someone have an idea that would be great I really starting to go crazy with this one…
Thank you in advance for your messages, here is the code used :
// We are in a method with this signature :
// private IEnumerator verifyServerURL()
string URL = "www.myServer.com/MyPage.php";
Debug.Log("Connection to [" + URL + "]");
// Preparing the web form
WWWForm form = new WWWForm();
form.AddField("Action", "DoSomething");
// Send the form to the server
WWW w = new WWW(URL, form);
// Wait for the result
yield return w;
// Result arrived
if (w.error != null) //ERROR
{
Debug.LogError("Server answer : " + w.error); // ALWAYS THROW HERE with a 404
// Clear the form
w.Dispose();
}
EDIT : SOLUTION
I digged into it :
The WWW will now add the prefix “http://localhost” if the specified URL does not contains “http://”.
It is still a problem since previous versions only added “http://” prefix
But it can be avoid by specifying the prefix at instantiation :
WWW w = new WWW(“http://” + yourServerAddress + “yourURLSuffix…”, form);
Just change that (and the w.error must now be tested as empty string if the form is valid - not null anymore, as mention in comments below)
For compatibility between all version :
if(!string.IsNullOrEmpty(w.error))
{
// There is an error
}
else
{
// No error
}
There were 2 problems in WWW class
EDIT : UNITY TEAMS’ ANSWER
Unity teams told me they were able to reproduce the bug, it should be fixed soon.
I recommend to submit a bug-report following the advice in this document. Using the bug-reporter seems to be an important step, because that makes sure the report is in their bug-tracking pipeline and has to be processed at some point. Using the forum is often used to add to a little more attention to an submitted bug-report, but does not replace it.
It’s from advantage to attach a project to the bug-report that Unity can use to reproduce the issue and test their fix against. The easier an issue can be reproduced by QA, the more likely it is to get forwarded to a developer, who might or might not work on a bug-fix for that at some point.
After you submitted the bug-report, you receive a confirmation email with a Case number. Unity often asks us to post the Case number in the forum thread, which allows them to find that bug-report if they look at your post.
Following these steps will increase the chance that Unity is looking at your issue tremendously.
Your not the first person to notice this. I was working on a script using the WWW class using Unity 5.6.1f1 setting a custom User-Agent string. Work perfectly in version 5.6.1f1 I upgrade yesterday to 2017.1 now I get a error that says invalid characters. The funny thing is I’m using a valid User-Agent string. I reported this as a bug yesterday. Please report you finding as a bug also so Unity can get this fixed ASAP. It seems to be a issue when setting custom headers.
Hello, not so sure about that since the www.error contains the string “404 Not Found”.
So maybe you didn’t try on 2017 version ?
Even more the www.text should be filled (as a server response, which not the case anymore)
But currently there is no way to get WWW to work in Unity 2017.
Still waiting for a fix, it’s a major issue, a real big one, if Unity 2017 can’t make WWW to work a lot of games will be impacted