连接尝试失败,因为连接方在 Azure 中一段时间​​后没有正确响应

A connection attempt failed because the connected party did not properly respond after a period of time in Azure

我有一个安装了 Windows 服务的 Azure VM。

在此 Windows 服务中,我们正在注册到 this 网站中提到的 EventHub。

我有这样记录错误的方法:

Task IEventProcessor.ProcessErrorAsync(PartitionContext context, Exception error)
{
    log.Error($"Error: {error.Message}");
    return Task.CompletedTask;
}

此 Windows 服务不断侦听事件中心,每当收到事件时,它都会根据事件(某些业务逻辑)执行一些处理。当处理发生时,它有时会在两者之间抛出这个错误。

Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

但过了一段时间后,它又恢复了正常处理。那么为什么会出现这些错误消息,它是否会自行解决。这对我没有造成任何问题,但想知道原因并希望在将来尽可能避免这种情况。我在网上搜索了很多,找不到任何合适的解决方案。

我认为您应该看一下 Azure Event Hubs quotas and limits and How exactly does Event Hubs Throttling Work?,因为根据您对问题的描述,您可能正在达到限制阈值。

希望对您有所帮助!

添加到@ItayPodhajcer 的回答中。

添加重试政策。在基于云的服务中出现瞬态连接错误是很常见的。请参阅此处的服务总线重试策略文档:

https://docs.microsoft.com/en-us/azure/architecture/best-practices/retry-service-specific#service-bus