- Home /
HttpWebRequest timed out behind proxy
Hi,
I try to access web services behind a proxy. Until now, I used unitywebrequest but I understood that proxy configuration wasn't handled by them. So I changed my code to use HttpWebRequest as it allows manual proxy configuration.
I wrote a simple code to test this, but I'm still getting timeout.
HttpWebRequest hwr = (HttpWebRequest)WebRequest.Create(ADMIN_URL);
hwr.Method = "HEAD";
hwr.Timeout = 5000;
WebProxy proxy = new WebProxy(PROXY_URL, true);
proxy.Credentials = new NetworkCredential(myLogin, myPassword);
hwr.Proxy = proxy;
try
{
using (HttpWebResponse response = (HttpWebResponse)hwr.GetResponse())
{
Debug.Log("response: " + response.StatusCode);
}
}
catch (Exception e)
{
Debug.Log("Serveur not reachable: " + e.GetBaseException().Message);
}
If I remove the proxy configuration (and use a connexion without proxy) it works. If i use the same code in a wpf .NET application (with proxy), it works.
I runned my tests through the Unity editor and with a pc standalone build.
My Unity version is 5.4.1f1
If you have any hint that can helps me... thank you
I'm facing the same problem. Has someone find a solution ?
Thanks :)
Your answer
Follow this Question
Related Questions
How can I decide between uLink and Unity Network? 2 Answers
Any way to speed up WWW requests? 2 Answers
WebRequest.BeginGetRequestStream fails on iOS using IPv6 DNS64/NAT64 1 Answer
UnityWebRequest returning responseCode 0 and isNetworkError == true for Unity 2019 1 Answer
Loading 3d objects at runtime 2 Answers