Calls to Azure Maps result in server disconnecting the client

Michael Landy 5 Reputation points
2025-05-15T19:28:21.68+00:00

We are making a .NET C# 4.8 call to the api: https://atlas.microsoft.com/search/address/json

The call may fail one or more times out of 10 calls. We are NOT calling it multiple times per second. We are passing in an address and waiting for the ___location to be returned. During this time, we get a failure rate in the call of 30-50%, which is crazy. We have it in a loop with an exponential backoff, and it still can fail 5+ times in a row. The exception is the Remote Server has closed the connection to our client. Why would it disconnect us so often? It is very unreliable.

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
826 questions
{count} votes

3 answers

Sort by: Most helpful
  1. rbrundritt 20,751 Reputation points Microsoft Employee Moderator
    2025-05-16T15:46:31.94+00:00

    First time I've come across anyone experiencing this. I'll assume you are calling the REST services directly with HTTPClient or something similar. A couple of things to check:

    • First, make sure you are escaping your the address you are passing into the query parameter. Special characters can cause issues in URLs. Here is how you do that in C# Uri.EscapeDataString(query)
    • I'm assuming you aren't making calls from within China or South Korea as is not available in those regions and trying to connect to Azure Maps from within one of those networks would fail.
    • Likely unrelated, but something to consider doing now while you are working with the code is to use the latest version of the search API. The endpoint you are referencing is v1 and there is a newer, more powerful search geocoding service available. https://learn.microsoft.com/en-us/rest/api/maps/search/get-geocoding?view=rest-maps-2025-01-01&tabs=HTTP
    • The search services usually respond within 300ms depending on your internet connection. If it is taking a lot longer than that (several seconds) then there is a networking issue such as a firewall that is causing issues.

    Beyond the above, we will need more information on how you are calling the services and a couple of example queries (excluding your subscription key of course).

    I know you said you weren't making multiple calls a second, but if you have a lot of addresses to geocode as part of a batch like process (e.g. geocoding a file or database of addresses), consider using the batch geocoding service: https://learn.microsoft.com/en-us/rest/api/maps/search/get-geocoding-batch?view=rest-maps-2025-01-01&tabs=HTTP

    2 people found this answer helpful.
    0 comments No comments

  2. Michael Landy 5 Reputation points
    2025-05-19T20:43:30.1533333+00:00

    Using the new URL did not help. I have tried this on 3 different PCs in 2 different places (internet connections) in Chicago and 2 different places in St. Louis. I can rule out a network firewall issues since all of the networks are different. I should also note that is does work 50% of the time but it is not robust even with 5 retries. The address is url encoded as described above, so that is not a problem either.

    Here is the error when attempting to geocode an address:

    System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

    The webview2 browser control gets an error and the map won't load because the atlas javascript files can't be downloaded so the map can't render. If I refresh that usually resolves the webview2 control. It happens about 50% of the time. The other 50% it will just work.

    Failed to load resource: net::ERR_CONNECTION_RESET

    atlas.min.js:1

                Failed to load resource: net::ERR_CONNECTION_RESET

    about:blank:25  Uncaught ReferenceError: atlas is not defined

        at initialize (about:blank:25:19)

        at onload (about:blank:16:45)


  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.