I suspect that you are trying to connect at a lower security level. See https://learn.microsoft.com/en-us/azure/azure-maps/azure-maps-authentication and ensure you are not using TLS 1.0 or TLS 1.1.
Azure Maps - SSL connection could not be established
I have Azure App Service that calls Maps API but get following error. What i am missing?
The SSL connection could not be established, see inner exception.
Exception:
System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
---> 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 (10054): An existing connection was forcibly closed by the remote host.
--- End of inner exception stack trace ---
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.GetResult(Int16 token)
at System.Net.Security.SslStream.<FillHandshakeBufferAsync>g__InternalFillHandshakeBufferAsync|182_0TIOAdapter
at System.Net.Security.SslStream.ReceiveBlobAsyncTIOAdapter
at System.Net.Security.SslStream.ForceAuthenticationAsyncTIOAdapter
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Boolean async, Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Boolean async, Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.SendAsyncCore(HttpRequestMessage request, HttpCompletionOption completionOption, Boolean async, Boolean emitTelemetryStartStop, CancellationToken cancellationToken)
at AzureMapsToolkit.Common.BaseServices.GetDataT
at AzureMapsToolkit.Common.BaseServices.ExecuteRequestT,U
at AzureMapsToolkit.AzureMapsServices.GetSearchAddress(SearchAddressRequest searchAddressRequest)
3 answers
Sort by: Most helpful
-
-
IoTGirl 3,131 Reputation points Microsoft Employee
2021-01-19T17:48:54.9+00:00 Can you provide a sample of the call you are making? Generally this can be caused by either calling at the wrong security level or malformed request.
-
Vinod Shinde 1 Reputation point
2021-01-19T17:52:01.327+00:00 It works sometime and sometimes does not. Does not work when call comes from mobile device to App Service.
private async Task<Point> GetGeoCordinatePointFromAzureMapsAsync(string searchAddress) { try { var am = new AzureMapsToolkit.AzureMapsServices(_configuration[Constants.AzureMaps.Key]); var searchAddressRequest = new SearchAddressRequest { Query = searchAddress, Limit = 1 }; var resp = await am.GetSearchAddress(searchAddressRequest); if (resp.Error != null) { //TODO: Handle Address Geo Coding Error } else { var firstResult = resp.Result.Results.FirstOrDefault(); if (firstResult != null) { return new Point(firstResult.Position.Lon, firstResult.Position.Lat); } } } catch(Exception ex) { _logger.LogError(ex, "Error in Azure Maps Address: " + searchAddress); } return null; }