Reputation: 893
I'm having the same problem as reported here: http://forums.xamarin.com/discussion/18907/system-net-webexception-error-connectfailure-network-is-unreachable
I upgraded Xamarin to v3, and my previously working app is no longer able to access any network, not even localhost. I can see full network access enabled in the deployed app on my Android 4.3 Galaxy SIII, while the emulator works. I've tried both RestClient shown below, and HttpWebRequest with the same results. Even using a new project using this recipe http://developer.xamarin.com/recipes/android/web_services/consuming_services/call_a_rest_web_service/ gives the same result. Everything is updated to current as far as I can tell.
var client = new RestClient("http://192.168.0.111");
var request = new RestRequest("api/item/getitems", Method.GET);
var response = _client.Execute(request);
if (response.ResponseStatus == ResponseStatus.Completed && response.StatusCode != HttpStatusCode.InternalServerError)
{
results = JsonConvert.DeserializeObject<IEnumerable<Item>>(response.Content).ToList();
}
else
{
throw new Exception(response.ErrorMessage);
}
The result is always "Error: ConnectFailure (Network is unreachable)"
Edit: I've updated Xamarin to 3.11, all packages to current, and now wireless works, but going over the mobile network returns "System.Net.WebException: Error: ConnectFailure (Connection refused)".
Upvotes: 3
Views: 959
Reputation: 893
The update to Xamarin 3.11 appears to have fixed this issue. That was the only difference between the original issue and starting to work.
Upvotes: 2