Search Unity

Unity 2017 - WWW 403 Forbidden Error [Bug?]

Discussion in 'Scripting' started by CavElliott, Jul 25, 2017.

  1. CavElliott

    CavElliott

    Joined:
    Mar 12, 2017
    Posts:
    6
    Hey Unity Forum, not entirely sure if this is a bug or if something has changed with WWW Class, however I upgraded my project which was working fine in Unity 5 to Unity 2017, since then whenever I use the WWW Class to post to a php file on a server I am getting 403 Forbidden errors.

    I have copied the string/url that it is posting to into my browser and it is working fine and like I said it was working fine in Unity 5, so not sure why this is not resulting in a 403 forbidden error.

    Here is the code used~

    string post_url = ""; // my url to php parser with parameters (?par1=meh) etc

    WWW post = new WWW(post_url);
    yield return post; // Wait until the download is done
    if (post.error != null)
    {
    Debug.LogError(post.error);
    }
    else
    {
    //success
    //but never gets here on Unity 2017
    }

    Not sure if this is actually a bug or if something has changed in 2017, will fill a bug report if someone can confirm this is not something wrong on my end.
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
  3. CavElliott

    CavElliott

    Joined:
    Mar 12, 2017
    Posts:
    6
    Thanks for the suggestion but tried that, now receiving "Generic/unknown HTTP error", which is just a 403 forbidden error.

    edit- I think the problem is on my end, tried the exact same code on "google.com" and it worked, not sure what the problem could be though (I have allowed access via crossdomain.xml).

    Edit2 - Solved I believe, after messing around I decided to double check my crossdomain settings to realize that my ftp was timing out, turns out my host blocked my ip thus resulting in all of these problems (I believe). Apparently they blocked me because of use of "libcurl", I am guessing this is something done by Unity 2017.

    Getting whitelisted now, will update if this resolves the issue.

    Edit3 - Yes this fixed the issue, thanks to any one who took the time to look at this :)
     
    Last edited: Jul 25, 2017
  4. Skylabs

    Skylabs

    Joined:
    Aug 25, 2017
    Posts:
    3
    Hi @CavElliott ,

    i have the same problem than you (The 403 Forbidden error) when downloading AssetBundle. It's working good on a Wamp Server with localhost but when i try to use my server with a domain, it give me that error ( " Failed downloading bundle Windows from https://***/assetBundle/Windows/Windows: 403 Forbidden ")

    Visibly you was able to fix that problem but i cannot understand how you did that ! Can you explain your solution widely please ? :)

    I tried to add a crossdomain.xml at the root of my domain :

    <?xml version="1.0"?>
    <cross-domain-policy>
    <allow-access-from domain="*"/>
    </cross-domain-policy>

    But it didn't change something.

    You talk about the host that blocked your adresse IP. But when i go with my browser and try to download the assetbundle, it's work with no problem so i'm bit lost ! If you can help me, i'll be glad :D
     
  5. elhispano

    elhispano

    Joined:
    Jan 23, 2012
    Posts:
    52
    Hi guys! Same problem here. We were downloading files from Amazon S3 bucket and everything was working fine until we updated to Unity 2017.
    Tried to put the crossdomain.xml in the bucket without any luck.

    Help please! :p
     
  6. elhispano

    elhispano

    Joined:
    Jan 23, 2012
    Posts:
    52
    Hi again.

    We solve this issues changing from WWW to UnityWebRequest. In our case we have the files uploaded to an Amazon S3 Bucket and we are downloading the files using https and also we add some headers to the request.
     
  7. tajino

    tajino

    Joined:
    Apr 4, 2014
    Posts:
    1
    I'm getting 403 forbidden error as well with either WWW or UnityWebRequest, what are the server side settings that I have to change? I've tried .htaccess and crossdomain.xml to allow access, but it is still not working.

    tried the same script with other url on other servers and it works.
     
    Last edited: Jan 31, 2018
  8. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    Are you doing POST requests to server?
    If so, try setting chunkedTransfer property to false on UnityWebRequest.
     
    tenh_un likes this.
  9. JeroenDG

    JeroenDG

    Joined:
    Oct 16, 2017
    Posts:
    5
  10. Zante

    Zante

    Joined:
    Mar 29, 2008
    Posts:
    429
    Getting this in the recent version of unity 2017 as well. Help!
     
    Last edited: May 19, 2018
  11. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    Are you using POST request with multipart sections?
    There is a known bug for this with fix in progress.
     
  12. Zante

    Zante

    Joined:
    Mar 29, 2008
    Posts:
    429
    Yes, though I've decided to compile my app launcher/auto updater in Unity 5.6 as it doesn't use libcurl and seems to work.

    On another note, while you're here - my Unity compiled app launcher has a custom resolution which can't be changed as long as an existing registry key relating to it exists. See the thread below for more details:
    https://forum.unity.com/threads/cant-change-resolution-for-standalone-build.323931/
     
  13. Keyserjaya99

    Keyserjaya99

    Joined:
    Nov 17, 2016
    Posts:
    10
    jonathaniscarroll likes this.
  14. tenh_un

    tenh_un

    Joined:
    Jun 24, 2019
    Posts:
    5
    I follow your idea but it doesn't work, any idea?
     
  15. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    If setting useHttpContinue and chunkedTransfer both to false doesn't help, then it's most likely the problem with your request, such as missing credentials to access resource.
     
  16. kygen007

    kygen007

    Joined:
    Feb 20, 2017
    Posts:
    8
    My first guess also was that it may be a permission issue.

    Or The URL you're trying to access is an "http" address while your site is hosted on an https server. https and http can not be mixed. The browser itself will block any http request from inside a https site.
    Your URL starts with http://www.yoursite.com NOT https://www.yoursite.com

    Also try to test your connection and run any VPN in background........
     
  17. NGHstar

    NGHstar

    Joined:
    Mar 20, 2019
    Posts:
    1
    The same problem - http error 403
    my problem was the host
    because the host was free and it was limited.
    i hope u can solve your problem.
     
  18. IsaGDC

    IsaGDC

    Joined:
    Jan 8, 2017
    Posts:
    6
    Good night,
    Although this has been open for a while now, wanted to raise the same issue.
    I'm trying to access through a GET petition to a .json file. However, I'm getting the 403 error too from Unity, while I can access the file from the browser.
    I've tried to change the .htaccess file without success, any ideas?

    I think I have the same issue @CavElliott had, but I'm not sure how did he change to have it whitelisted in his server.
    I'm using Unity 2018.4.36f1 and UnityWebRequest,
    Thanks in advance,
     
  19. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,697