最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Azure Service Bus: Unable to connect to the remote server error while adding a message - Stack Overflow

programmeradmin1浏览0评论

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
  • Use a singleton ServiceBusClient to avoid connection exhaustion and check SNAT port usage in App Insights – Dasari Kamali Commented Mar 19 at 3:38
  • @DasariKamali Thanks for the feedback. It's definitely a possibility. I discovered yesterday that the App Service was on .NET V6 and the application is configured for .NET V8. I've since updated that setting, and so far... the issue seems to have been resolved. Continuing to monitor, but for now just hoping the version change does the trick. Thanks! – nesterenes Commented Mar 19 at 17:18
Add a comment  | 

1 Answer 1

Reset to default 1

You 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.

发布评论

评论列表(0)

  1. 暂无评论