I need to find out the name of the city given a pair of lat
,lon
coordinates
I'm using Nominatim API https://wiki.openstreetmap.org/wiki/Nominatim
This is an example query:
https://nominatim.openstreetmap.org/reverse?format=xml&lat=40&lon=30&zoom=18&addressdetails=1
And it works from the Browser, however it fails from this C# code:
ServicePointManager.Expect100Continue = true;
ServicePointManager.DefaultConnectionLimit = 9999;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
var url = "https://nominatim.openstreetmap.org/reverse?format=xml&lat=40&lon=30&zoom=18&addressdetails=1";
var request = (HttpWebRequest)WebRequest.Create(url);
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
I get the following exception:
The underlying connection was closed: The connection was closed unexpectedly.
No idea why as the code above works perfectly fine for other APIs and the query works on a Browser
Does it always fail or just sometimes?
Currently some OSM servers are moved from London to Amsterdam. The API and possible other services (such as Nominatim) run on backup hardware until the primary servers are up again. This will degrade performance and can also lead to sporadic problems. See https://lists.openstreetmap.org/pipermail/talk/2018-July/081009.html . You can check the current state at https://twitter.com/osm_tech .