英文:
Cannot access a disposed object. Object name: 'tlsxyz'
问题
我在从Azure函数发送消息到Azure Service Bus(标准)主题时遇到了一个随机错误。
错误消息如下:
无法访问已释放的对象。对象名称:'tls2576',堆栈跟踪:
在 Microsoft.Azure.ServiceBus.Core.MessageSender.OnSendAsync(IList1 messageList) 中 在 Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func
1 operation, TimeSpan operationTimeout) 中
在 Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func1 operation, TimeSpan operationTimeout) 中 在 Microsoft.Azure.ServiceBus.Core.MessageSender.SendAsync(IList
1 messageList) 中
在 ServiceBusFunctions.MyTopic.Run(HttpRequest req, ILogger log, ExecutionContext context) 中,我的Azure函数
有时错误中的对象名称是'tls2716'。
该代码运行在一个包含3个函数的Azure函数实例中。有2个冗余的函数应用程序,其中包含相同的代码,从应用程序网关中以轮询的方式调用。用于将消息发送到主题的客户端代码如下:
var message = new Message(Encoding.UTF8.GetBytes(requestBody));
// 主题路由的自定义属性
message.UserProperties.Add("P1", P1);
message.UserProperties.Add("P2", P2);
message.UserProperties.Add("P3", P3);
ITopicClient topicClient = new TopicClient(SBConnectionString, CCTopicName);
await topicClient.SendAsync(message);
await topicClient.CloseAsync();
感谢您的帮助。
英文:
I'm facing a random error when sending message from an Azure function to an Azure Service Bus (Standard) Topic.
the message error is:
> Cannot access a disposed object. Object name: 'tls2576'., Stacktrace :
> at Microsoft.Azure.ServiceBus.Core.MessageSender.OnSendAsync(IList1
1 operation,
> messageList) at
> Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func
> TimeSpan operationTimeout) at
> Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func1 operation,
1
> TimeSpan operationTimeout) at
> Microsoft.Azure.ServiceBus.Core.MessageSender.SendAsync(IList
> messageList) at ServiceBusFunctions.MyTopic.Run(HttpRequest req,
> ILogger log, ExecutionContext context) in myAzureFunction
sometimes the object name in the error is 'tls2716'.
The code is running from an Azure function instance containing 3 functions. Tere are 2 redundant functions APP containing the same code called in round robin from an Application Gateway. The client code to send messages to the topic is:
var message = new Message(Encoding.UTF8.GetBytes(requestBody));
//Custom properties for topis routing
message.UserProperties.Add("P1", P1);
message.UserProperties.Add("P2", P2);
message.UserProperties.Add("P3", P3);
ITopicClient topicClient = new TopicClient(SBConnectionString, CCTopicName);
await topicClient.SendAsync(message);
await topicClient.CloseAsync();
thanks for your help
答案1
得分: 1
问题是在一个并发调用正在使用静态主题客户端时关闭它。修复方法是不关闭主题客户端以便重用它,并在打开连接时最小化连接数和性能调优。
英文:
The problem was closing the static topic client when a conccurent call is using it. the Fix is not to close the topicclient to reuse it and minimze the number of connection and tunning performance when open a connection
答案2
得分: 0
这是因为在从内存中清除后访问已释放的对象而发生的。
英文:
This happens due to accessing the disposed objected after clearing from memory.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论