Quantcast
Channel: Questions in topic: "webrequest"
Viewing all articles
Browse latest Browse all 387

HttpClient with Proxy

$
0
0
I am unable to make web requests in unity targeting mono with a configured proxy. I am using HttpClient and Unity 2019.2.18f1. When running this exact same code in a .NET core console app, I have no problems. When I run this code in unity, I am greeted with this error: **WebException: (407) Proxy Authentication Required** I have verified the DefaultCredentials objects are the same in my console app and in unity editor. In fact, the proxy is even wide open. Here is the sample code: var clientHandler = new HttpClientHandler(); clientHandler.UseProxy = true; clientHandler.Proxy = new WebProxy("http://myproxy:3128"); clientHandler.Proxy.Credentials = CredentialCache.DefaultCredentials; clientHandler.UseDefaultCredentials = true; var httpclient = new HttpClient(clientHandler); var result = httpclient.GetStringAsync("https://google.com").Result; I have tried tried targeting .NET Framework 4.X and .Net standard 2.0 with no luck. I have set HTTP_proxy and HTTPS_proxy environment variables with no luck. I have tried using UnityWebRequest, HttpWebRequest, and WebClient with no luck. I have tried editor and standalone builds with no luck. I have tried manually setting headers with no luck. How is this supposed to work in an enterprise environment where users have to specify proxy creds? Has anybody solved this? Am i doing something wrong?

Viewing all articles
Browse latest Browse all 387

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>