无法访问已释放的对象。对象名称:’tlsxyz’

huangapple go评论69阅读模式
英文:

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(Func1 operation, TimeSpan operationTimeout) 中
在 Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func1 operation, TimeSpan operationTimeout) 中 在 Microsoft.Azure.ServiceBus.Core.MessageSender.SendAsync(IList1 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
> 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'.

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.

huangapple
  • 本文由 发表于 2020年1月6日 18:35:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/59610541.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定