c# - 发送消息时服务总线未知错误 (0xffffffff)
问题描述
我有一个连接到服务总线队列的 Azure 应用服务 API。一切都工作了一段时间,但后来我开始遇到这些错误:
System.AggregateException: One or more errors occurred. (Unknown error (0xffffffff) ErrorCode: SocketError) ---> Microsoft.Azure.ServiceBus.ServiceBusCommunicationException: Unknown error (0xffffffff) ErrorCode: SocketError ---> System.Net.Sockets.SocketException: Unknown error (0xffffffff)
at Microsoft.Azure.ServiceBus.ServiceBusConnection.CreateConnectionAsync(TimeSpan timeout)
at Microsoft.Azure.Amqp.FaultTolerantAmqpObject`1.OnCreateAsync(TimeSpan timeout)
at Microsoft.Azure.Amqp.Singleton`1.GetOrCreateAsync(TimeSpan timeout)
at Microsoft.Azure.Amqp.Singleton`1.GetOrCreateAsync(TimeSpan timeout)
at Microsoft.Azure.ServiceBus.Amqp.AmqpLinkCreator.CreateAndOpenAmqpLinkAsync()
at Microsoft.Azure.ServiceBus.Core.MessageSender.CreateLinkAsync(TimeSpan timeout)
at Microsoft.Azure.Amqp.FaultTolerantAmqpObject`1.OnCreateAsync(TimeSpan timeout)
at Microsoft.Azure.Amqp.Singleton`1.GetOrCreateAsync(TimeSpan timeout)
at Microsoft.Azure.Amqp.Singleton`1.GetOrCreateAsync(TimeSpan timeout)
at Microsoft.Azure.ServiceBus.Core.MessageSender.OnSendAsync(IList`1 messageList)
--- End of inner exception stack trace ---
at Microsoft.Azure.ServiceBus.Core.MessageSender.OnSendAsync(IList`1 messageList)
at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func`1 operation, TimeSpan operationTimeout)
at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func`1 operation, TimeSpan operationTimeout)
at Microsoft.Azure.ServiceBus.Core.MessageSender.SendAsync(IList`1 messageList)
public async Task SendAsync(string message)
{
var queueMessage = new Message(Encoding.ASCII.GetBytes(message));
var queueClient = GetQueueClient("myqueue");
await queueClient.SendAsync(queueMessage);
}
public IQueueClient CreateQueueClient(string queueName)
{
var messageBusSection = _configuration
.GetSection("AppSettings:MessageBus");
var connectionString = messageBusSection["ConnectionString"];
var path = messageBusSection.GetSection("Queues")[queueName];
return new QueueClient(connectionString, path);
}
我认为这不是超出配额的问题,也没有说超时。关于如何调试这个的任何想法?
解决方案
注意:这不一定能解决您的问题(因为错误描述性不是很强)。
使用 ASB 消息传递的最佳实践之一是重用工厂和客户端:
建议您发送消息后不要关闭消息工厂或队列、主题和订阅客户端,然后在发送下一条消息时重新创建它们。
您可能只是遇到了某种连接限制,可以通过重用QueueClient
而不是在每次发送消息时重新创建它来解决。
推荐阅读
- python - 即使在 python 中关闭 tkinter 窗口,是否可以运行某些代码?
- node.js - 如何发布网址
- jquery - 使用mongodb在nodejs中选择国家/地区城市
- python - 使用 ajax jquery 搜索表单
- python - 尝试用一个数字输入编写函数。如果数字 <= 0,则返回 -1。如果数字 > 0,则将该整数一遍又一遍地除以 2
- python - Instaloader 给出 KeyError: 'entry_data'
- python - BeautifulSoup 显示奇怪的文字
- vue.js - 如何在 vue-multiselect 中删除预选标签
- javascript - 从 AsyncStorage 更新数组
- php - Wordpress | Split queries based on selection