I have many problems using WebRecests in MonoDroid and getting timeouts at random. My code works fine, and sometimes all requests just time out and don't work.
I checked that the web services used in my requests are not a problem.
Here is an example of some code that I can use to request some data from a web service using MonoDroid:
bool bolOk = false; HttpWebRequest request = (HttpWebRequest)WebRequest.Create ("http://www.website.com/service/"); request.Timeout = 20000; request.Credentials = gv_objCredentials; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse ()) { bolOk = response.StatusCode == HttpStatusCode.OK; }
As you can see, this is the main material. I am using code as above in another thread in the user interface using ThreadPool.QueueUserWorkItem or TaskFactory.
What I noticed is that if the requests start to count the time from my application, and I connect it to my computer, then debug the application from MonoDevelop, working without a chronometer. I'm not sure what this means. This is similar to testing web services from my computer using a browser on the same network as the phone. Web services always work without any problems.
What is the best way to create Web requests from MonoDroid?
How can I ensure that my requests are always successful and there will not be a timeout if the web service is working correctly?
source share