Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

UnityWebRequest proxy environment variables overridden by system proxy settings

Discussion in 'Editor & General Support' started by pwroames, Feb 7, 2018.

  1. pwroames

    pwroames

    Joined:
    Jan 16, 2018
    Posts:
    2
    I am having an issue running Unity behind a proxy with a particular setup in Windows.

    Normally I would provide the environment variables of http_proxy and https_proxy with the proxy details
    Code (csharp):
    1. http/s://username:password@hostname:port
    That would usually suffice with the Proxy-Authorisation header is sent across with the HTTP requests

    upload_2018-2-7_17-28-40.png

    However in this instance the user also has a system level proxy configured with basic username and password authentication. This appears to result in the environment variable proxy configuration being ignored. That in itself would be OK as it is the same proxy server but when using the system proxy config Unity does not provide the Proxy-Authorisation header in the http requests. This results in 407 Proxy Authentication Required response and no traffic getting through.

    Is there a way to manually provide the authentication details in the case that it uses the system proxy config or force unity to use the config from the environment variables?

    Platform: Windows build
    Unity version: 2017.1.2

    I have tried manually setting the Proxy-Authorisation header with the following line

    Code (csharp):
    1. request.SetRequestHeader("Proxy-Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes("Basic test:1234")));
    This would be a horrible work around and probably to be expected results in the exception:

    upload_2018-2-7_17-45-17.png

    Has anyone found a solution to this that I am missing?
     
    Last edited: Feb 8, 2018
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,635
    chris_hull likes this.
  3. pwroames

    pwroames

    Joined:
    Jan 16, 2018
    Posts:
    2
    Cheers Aurimas-Cernius,

    This is exactly what I was after.
     
  4. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,271
    @Aurimas-Cernius when was this added pls ?
    I'm trying to set a proxy automatically per process for users for different Unity versions -
    ( I believe HTTP_proxy/HTTPS_proxy variables can be used too ? Do these all follow WWW/UnityWebRequest introduction ?)

    Thank you!
     
  5. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,635
    I don't know when exactly these were added, but it was quite a long time ago. WWW/UnityWebRequest does not use HTTP_proxy/HTTPS_proxy environment variables with exception for Linux.
     
    r618 likes this.
  6. chris_hull

    chris_hull

    Joined:
    Mar 13, 2020
    Posts:
    2
    this is what I needed thanks, took a while to find, this should probably be better documented along with the other proxy settings unity pulls in