How to resolve "Connection Refused" from .NET HttpClient when URL works fine from browser
<p>This is Xamarin app which is accessing the www.geonames.org site.  When I run it, it generates a System.Net.WebException "Error: ConnectFailure (Connection refused)".  However, if I take the url produced in this method and paste it into a browser on the simulator, it works fine and returns the correct JSON.</p>

<pre><code>    public async Task GetWeatherAsync(double longitude, double latitude, string username)
    {
        var url = string.Format("http://api.geonames.org/findNearByWeatherJSON?lat={0}&amp;lng={1}&amp;username={2}", latitude, longitude, username);

        HttpClient client = new HttpClient();
        client.BaseAddress = new Uri(url);

        try
        {
            var response = await client.GetAsync(client.BaseAddress);
            if (response.IsSuccessStatusCode)
            {
                var JsonResult = response.Content.ReadAsStringAsync().Result;
                var weather = JsonConvert.DeserializeObject&lt;WeatherResult&gt;(JsonResult);

                SetValues(weather);
            }
            else
            {
                Debug.WriteLine(response.RequestMessage);
            }
        }
        catch (HttpRequestException ex)
        {
            Debug.WriteLine(ex.Message);
        }
        catch (System.Net.WebException ex)
        {
            Debug.WriteLine(ex.Message);
        }
        catch (Exception ex)
        {
            Debug.WriteLine(ex.Message);
        }
    }
</code></pre>