Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Infinite Timeout with HttpWebRequest on some URLs

$
0
0

Hei Guys,

i need to communicate in an iOS App with an WCF - Service. So VS created some Proxy-Classes and all Works fine and well. Also the Timeouts work well. But if the Communication is made over a local adress, and we are not in the WIFI, the app hangs forever after the second call to the websevice is made. The Timeout works on the first Request well, but in the second request the timeout never will be executed.

The problem is not the WCF Generated Code it is reproducable with a Simple HttpWebRequest. After the second call, the app hangs forever.

Code that reproduces the Problem:

`public override void ViewDidLoad()
{
base.ViewDidLoad();
ServicePointManager.MaxServicePointIdleTime = 1000;
ServicePointManager.DnsRefreshTimeout = 1000;
}

partial void UIButton220_TouchUpInside(UIButton sender)
{
txtViewArea.Text += "\n URL-Reachable-Test: ";

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https" + ":// + "sg.eurowig.local/");

request.Timeout = 1000;
request.ContinueTimeout = 1000;
request.ReadWriteTimeout = 1000;
request.KeepAlive = false;
request.ServicePoint.MaxIdleTime = 1000;
request.Method = "HEAD"; // As per Lasse's comment
try
{
    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
    {
        txtViewArea.Text += "OK";
    }
}
catch (WebException exc)
{
    txtViewArea.Text += "ERROR\n--" + exc.Message;
}
finally
{
    request.Abort();
    request = null;
    GC.Collect();
}

}`

As you See i tried already some Timeouts-Props of the WebRequest-Object but nothing helps.

Does anyone have a clue how to do this the right way?

Thanks in advance.

PS: the formation of the link is, because i cant post here, links...


Viewing all articles
Browse latest Browse all 204402

Trending Articles