Search Unity

WebException: Error: NameResolutionFailure only on Android mono builds

Discussion in 'Scripting' started by zlSimon, Nov 4, 2015.

  1. zlSimon

    zlSimon

    Joined:
    Apr 11, 2013
    Posts:
    31
    Hi,

    I have a managed unity plugin where I send out a simple GET webrequest via Https using the .Net webclient class. This works fine in the Editor or on IOS (IL2CPP) and I am getting a valid response.
    However on an Android mono build I receive followin error:

    D/dalvikvm( 4106): GC_CONCURRENT freed 524K, 23% free 9880K/12720K, paused 12ms+2ms, total 78ms
    W/mono (23070): _wapi_gethostbyname: Need to translate 0 into winsock error
    I/Unity (23070): WebException: Error: NameResolutionFailure
    I/Unity (23070): at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
    I/Unity (23070): at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0
    I/Unity (23070): at System.Net.WebClient.GetWebResponse (System.Net.WebRequest request) [0x00000] in <filename unknown>:0
    I/Unity (23070): at System.Net.WebClient.DownloadDataCore (System.Uri address, System.Object userToken) [0x00000] in <filename unknown>:0

    Anyone any ideas?
     
  2. zlSimon

    zlSimon

    Joined:
    Apr 11, 2013
    Posts:
    31
    Oh and I did forget to mention that this error does not occur when I enable the "script debuggin" checkbox for a build
     
  3. zlSimon

    zlSimon

    Joined:
    Apr 11, 2013
    Posts:
    31
    Well it works when setting the "Internet Access" checkbox to "required" in the Player settings...
     
    mrwellmann_, animusz_, ejhova and 5 others like this.
  4. yoyo696

    yoyo696

    Joined:
    Aug 11, 2015
    Posts:
    14
    thanks so much. It works Perfectly
     
    ejhova and Chastom like this.
  5. skysepehr

    skysepehr

    Joined:
    Jun 4, 2019
    Posts:
    1
    that worked ,Thanks!
     
  6. mrwellmann_

    mrwellmann_

    Joined:
    Jan 25, 2013
    Posts:
    4
    Thanks for the tip!
    Under 2021 it changed a bit there is now a selector with Auto and Require in the player settings.

    I think the reason for this is that on Auto Unity only adds the parts of the mono implementation of System.Net when it thinks it is needed (Managed Stripping). I have some usage dependency inception which is of course not recognized by Managed Stripping.

    Weirdly using a link.xml file did not help me.
     
  7. JoshW_3

    JoshW_3

    Joined:
    Sep 11, 2013
    Posts:
    7
    For me, ticking Require on the Internet Access setting hasn't fixed the issue.
    I've tried solving the ip address myself and and using that as the domain but that didn't help either