locked
Cannot access a disposed object. Object name: 'tlsxyz' RRS feed

  • Question

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

    Monday, January 6, 2020 10:26 PM

Answers

  • 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
    • Marked as answer by Hichamveoo Wednesday, January 29, 2020 5:00 PM
    Wednesday, January 29, 2020 4:59 PM

All replies

  • Considering where the error was thrown, I believe this is a transient error from the underlying transport. For such errors, the best approach is to setup a retry policy.

    Tuesday, January 7, 2020 10:20 AM
  • 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
    • Marked as answer by Hichamveoo Wednesday, January 29, 2020 5:00 PM
    Wednesday, January 29, 2020 4:59 PM