Using Azure Service Bus - Azure Function Triggers, we're experience an intermittent "Unable to connect to the remote server" error while adding messages to the queue. It occurs while processing a Durable Function OrchestrationTrigger with ActivityTriggers. The first 50-60 requests succeed, but all following requests fail. It also only occurs on Production, and cannot be reproduced on Test. I've compared the settings for the Service Bus Queue for both environments, and they match. I've also confirmed that Web Sockets is turned for the Azure Function app.
Infrustructure
- .NET Core v8 Isolated
What could be causing the "Unable to connect to the remote server" error, and what steps can I take to resolve it?
Using Azure Service Bus - Azure Function Triggers, we're experience an intermittent "Unable to connect to the remote server" error while adding messages to the queue. It occurs while processing a Durable Function OrchestrationTrigger with ActivityTriggers. The first 50-60 requests succeed, but all following requests fail. It also only occurs on Production, and cannot be reproduced on Test. I've compared the settings for the Service Bus Queue for both environments, and they match. I've also confirmed that Web Sockets is turned for the Azure Function app.
Infrustructure
- .NET Core v8 Isolated
What could be causing the "Unable to connect to the remote server" error, and what steps can I take to resolve it?
Share Improve this question asked Mar 18 at 18:24 nesterenesnesterenes 2345 silver badges19 bronze badges 2 |1 Answer
Reset to default 1You are right @nesterenes, intermittent connection issues like "Unable to connect to the remote server" can occur due to version incompatibility of the function app, .NET SDK for Service Bus or the Azure Functions SDK.
Make sure you're using the latest stable versions of the Azure Service Bus NuGet package and Azure Functions SDK for your isolated worker.
Make sure you have selected .NET 8.0 Isolated as runtime stack of your function App in portal.
The Runtime version of function App should match with Target Framework of your function project.
.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.1.7" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
</Project>
If you still face the issue, monitor the application logs under Application Insights or Log Stream of the function app.
ServiceBusClient
to avoid connection exhaustion and check SNAT port usage in App Insights – Dasari Kamali Commented Mar 19 at 3:38