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

Infinite Timeout after second HttpWebRequest

$
0
0

Hei Guys,

we have a iOS Application which communicates via a WCF Webservice with our own Webservice. We implemented the WcfProxy with Visual Studio and all Works well. Now one of our customers has a unique problem. He uses a vpn to obtain a connection from the mobile device to our webservice. Sometimes the vpn is not correctly loaded and our app tries to open a connection to an internal webservice adress. If this happens the first request via the HttpWebRequest (used in the generated WcfProxy) will trigger after the set timeout period a timeout exception (so far, so good). Now if we call a secondary method of the WcfProxy to this (not existing) Url the HttpWebRequest will never come back and will stay forever. Only we can accompolish a connection to the vpn, then the function will correctly excuted.

This problem can be replicated by following simple function:

    //---Format for Forums-Post changed to don't look like a Url ;-)
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https" + "://" + "sg.eurowig.local" + "/" + "abc.html"); 


        request.Timeout = 1000;
        request.ContinueTimeout = 1000; //Try
        request.ReadWriteTimeout = 1000;  //Try
        request.KeepAlive = false;  //Try
        request.ServicePoint.MaxIdleTime = 1000;  //Try
        request.Method = "HEAD"; //Try
        try
        {
            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                //Console.Log("We reached the destination");
            }
        }
        catch (WebException exc)
        {
            //Console.Log(exc);
        }
        finally
        {
            request.Abort(); //Try
            request = null; //Try
            GC.Collect(); //Try
        }

My expirience so far:

  • Compiled on Visual Studio for Mac 7.7.3 on an iPhone 8 Plus with iOS 12.1
  • >> No timeout on second call
  • Compiled with Visual Studio for Windows 2017 on an iPhone 8 Plus with iOS 12.1
  • >> No timeout on second call
  • Tried with an not existing URL like "my.domain.that.does.not.exist"
  • >> Direct exception - Cant resolve hostname << Works
  • Different settings in the HttpWebRequest Object, as u see on the //Try comment each line...
  • >> No timeout on second call

Anyone an ideas, how to run into the timeout in the second call?

thanks in advance too you guys,
Sascha


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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