【发布时间】:2018-01-09 17:18:32
【问题描述】:
尝试向 Azure 事件中心发送消息时,我偶尔会在事件中心客户端中看到超时错误。看起来客户端已达到资源限制,但我不确定... 代码如下:
MessagingFactory messagingFactory = null;
EventHubClient hubClient = null;
try
{
messagingFactory = MessagingFactory.CreateFromConnectionString(this.connectionString);
hubClient = messagingFactory.CreateEventHubClient(this.configurationManager.EventHubName);
var batchIterator = new EventBatchIterator<T>(events);
foreach (var batch in batchIterator)
{
await hubClient.SendBatchAsync(batch);
}
}
catch (Exception e)
{
this.logger.Error("An error occurred during sent messages to event hub", e);
}
finally
{
if (hubClient != null)
{
await hubClient.CloseAsync();
}
if (messagingFactory != null)
{
await messagingFactory.CloseAsync();
}
}
例外是:
与“N/A”通信时出错。检查 连接信息,然后重试。 Microsoft.ServiceBus.Messaging.MessagingCommunicationException
连接尝试失败,因为连接方没有 一段时间后正确响应,或建立连接 失败,因为连接的主机没有响应 System.Net.Sockets.SocketException
【问题讨论】:
标签: c# azure azure-eventhub