Reputation: 750
I have a blob triggered azure function (v2) hosted with App Service plan(S3)
. The function process a json file and makes Http calls
to APIs exposed in API management service.
I'm using HttpClient
to make Http
calls. Although this works fine in one environment with same set up, it is failing while making http post calls in another environment.
The exception :
System.Net.Sockets.SocketException
with error message "The operation was canceled. Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request. The I/O operation has been aborted because of either a thread exit or an application request"
Quick googling revealed me that it may happen because of excess http connections. More details here :
https://learn.microsoft.com/en-us/azure/azure-functions/manage-connections#connections-limit
The solution was to use static HttpClient
or scale out App service plan. I did both only to realise that it still fails with same exception.
Has any one encountered this issue?
Any insights would be helpful.
Edit: Here is the code that makes http call
public class ReportingService : IReportingService
{
private static readonly HttpClient _httpClient = new HttpClient();
private readonly ILogger _logger;
public ReportingService(ILogger<ReportingService> logger, IConfigurationRoot configuration)
{
_logger = logger;
_httpClient.BaseAddress = new Uri(configuration["ReportingServiceBaseUrl"]);
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.UTF8.GetBytes($"{configuration["APIUser"]}:{configuration["APIPassword"]}")));
}
public async Task<bool> RequestReport(string endpoint, StringContent httpContent)
{
try
{
var response = await _httpClient.PostAsync(endpoint, httpContent);
return response.IsSuccessStatusCode;
}
catch (Exception ex)
{
_logger.LogError(ex, "Migration failed");
throw;
}
}
}
Upvotes: 3
Views: 2174
Reputation: 1811
From the back-end logs there is only execution and unfortunately that is failed one.
Exception Details
Timestamp : 7/2/2019 6:49:55 AM Inner Exception Type: System.FormatException
Full Exception :
System.FormatException : Invalid blob path specified : ''. Blob identifiers must be in the format 'container/blob'.
at Microsoft.Azure.WebJobs.Host.Blobs.BlobPath.ParseAndValidate(String value,Boolean isContainerBinding) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Blobs\BlobPath.cs : 53
at Microsoft.Azure.WebJobs.Host.Blobs.Triggers.StringToCloudBlobConverter.ConvertAsync(String input,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Blobs\Triggers\StringToCloudBlobConverter.cs : 21
at async Microsoft.Azure.WebJobs.Host.Blobs.BlobOutputConverter`1.TryConvertAsync[TInput](Object input,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Blobs\BlobOutputConverter.cs : 35
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Converters.CompositeAsyncObjectToTypeConverter`1.TryConvertAsync[T](Object value,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Converters\CompositeAsyncObjectToTypeConverter.cs : 28
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Blobs.Triggers.BlobTriggerBinding.BindAsync(Object value,ValueBindingContext context) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Blobs\Triggers\BlobTriggerBinding.cs : 158
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.TriggerWrapper.BindAsync(Object value,ValueBindingContext context) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs : 475
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Triggers.TriggeredFunctionBinding`1.BindCoreAsync[TTriggerValue](ValueBindingContext context,Object value,IDictionary`2 parameters) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Triggers\TriggeredFunctionBinding.cs : 57
Please let me know if there is any date and time in UTC in which you observe
System.Net.Sockets.SocketException
Upvotes: 1