[英]Cannot access a disposed object. Object name: 'tlsxyz'
I'm facing a random error when sending message from an Azure function to an Azure Service Bus (Standard) Topic.从 Azure 函数向 Azure 服务总线(标准)主题发送消息时,我遇到随机错误。
the message error is:消息错误是:
Cannot access a disposed object.
无法访问已处置的对象。 Object name: 'tls2576'., Stacktrace : 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(Func1 operation, TimeSpan operationTimeout) at Microsoft.Azure.ServiceBus.Core.MessageSender.SendAsync(IList
1 messageList) at ServiceBusFunctions.MyTopic.Run(HttpRequest req, ILogger log, ExecutionContext context) in myAzureFunction对象名称:'tls2576'., Stacktrace:在 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(Func1 operation, TimeSpan operationTimeout) at Microsoft.Azure.ServiceBus.Core.MessageSender.SendAsync(IList
1 messageList) at ServiceBusFunctions.MyTopic.Run(HttpRequest req, ILogger log, ExecutionContext context) in myAzureFunction
sometimes the object name in the error is 'tls2716'.有时错误中的对象名称是“tls2716”。
The code is running from an Azure function instance containing 3 functions.代码从包含 3 个函数的 Azure 函数实例运行。 Tere are 2 redundant functions APP containing the same code called in round robin from an Application Gateway.
有 2 个冗余功能 APP 包含从应用程序网关循环调用的相同代码。 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感谢您的帮助
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
修复是不关闭主题客户端以重新使用它并在打开连接时最小化连接数量和调整性能
发生这种情况是由于在从内存中清除后访问已处理的对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.