Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 6420 [details]
We are constantly getting this error on Xamarin.Android 4.12.2 lately and it has also been brought to my attention by clients.
When we start our app we call an initialize web service. The exact address of this is https://prod.affinionmobile.com/ams/
Often now days we are returned with an Error: NameResolutionFailure. A retry then normally succeeds. It is not consistent nor is it always reproduceable, but I have been trying everything to mitigate this error and I have come up short. The exact same code works flawlessly on Xamarin.iOS and Windows Phone.
Before all calls I now run this code to try help resolve what looks to be a DNS problem:
System.Uri uri = new System.Uri(InitializationController.GetWebServiceURL());
var ip = Dns.GetHostEntry(uri.Host);
However this does not help and the error still persists. Does this have anything to do with https? Is there something else I need to do to try and resolve this issue? Must I build in logic to retry the web service for a 2nd time if the first time failed?
Attached is the application output for when the service runs. You'll notice a "prod.affinionmobile.com resolved!" output and then not too far below will be the NameResolutionFailure.
Could this maybe not be the problem?
[Mono] AOT module 'Mono.Security.dll.so' not found: dlopen failed: library "/data/data/com.Conference.MD/lib/Mono.Security.dll.so" not found
Any further insight or assistance will be greatly appreciated.
> Could this maybe not be the problem?
> Error: NameResolutionFailure
What would be helpful is if you print Exception.ToString() instead of Exception.Message, so that the full stack trace is provided.
That said, it's possible (probable) that you're running out of file descriptors; see Bug #15135 and https://bugzilla.xamarin.com/show_bug.cgi?id=13750#c16.
If this is the issue you're seeing (and I suspect it is), the workaround is for you to call GC.Collect() "occasionally" in order to ensure that the Sockets are GC'd and the associated file descriptors are freed.
Alright I am going to catch the stack traces for you.
We normally notice this problem as soon as the app loads. Surely I shouldn't have to call GC.Collect() that early in the life cycle? I'll also try and let you know.
Got a stack trace. Full trace and app output logged.
System.Net.WebException: Error: NameResolutionFailure
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.TaskFactory`1[System.Net.WebResponse].InnerInvoke (System.Threading.Tasks.TaskCompletionSource`1 tcs, System.Func`2 endMethod, IAsyncResult l) [0x00000] in <filename unknown>:0
Something strange happening with the HttpWebRequest? As I said, before doing any web request call on Android I check that there is an active connection, followed by Dns.GetHostEntry(uri.Host). There should not no reason that a NameResolutionFailure happens after these checks.
Btw my manifest does definitely include the Internet permission.
Created attachment 6436 [details]
app output with stack trace
Is this a Debug or a Release app? Release apps don't get INTERNET permission by default, and the iNTERNET permission is required in order to access network resources. (Debug apps get INTERNET permission so that the debugger can attach.)
I doubt this is the case, as that would impact _all_ network connections, and you state that a "retry then normally succeeds," which implies that the INTERNET permission is present.
Would it be possible for you to provide a repro?
Happens for debug and release. Internet permission is definitely present.
I'll try my best to make a repro. Right now I've used Dns.GetHostEntry to rather call the web service via the IP Address instead of the hostname.
A side note: I get Error: NameResolutionFailure on Xamarin.iOS when in airplane mode and trying to call the web service.
> I get Error: NameResolutionFailure on Xamarin.iOS when in airplane
> mode and trying to call the web service
"Airplane mode" == "No network connection" (unless Wi-Fi is separately enabled), so this makes perfect sense: you get NameResolutionFailure because there's no operating network stack to perform the name resolution request.
May be related to: https://bugzilla.xamarin.com/show_bug.cgi?id=15135
This bug still exists in my app using Android 4.14
Thank you for taking the time to submit this report. Are you are still experiencing the issue after updating to the latest version of Xamarin.Android? If so, please reopen this report with an attached reproduction or steps to reproduce the issue. Thanks!