azure-sdk-for-python: Service Bus python SDK output log shows 3s interval before throw exception.

  • Package Name: azure_servicebus
  • Package Version: 7.11.2
  • Operating System:Azure Function App
  • Python Version: TBD

Describe the bug

  1. The latency issue occurs intermittently without any pattern when send message to service bus standard tier namesapce.
  2. When the code running without latency, the application log is like this: image
  3. When the code running with latency, I can see 2 exceptions, “AMQPConnectionError('Error condition: ErrorCondition.SocketError” and "AMQPLinkError(“Error condition: amqp🔗detach-forced”. The traffic is public to public, client side is without high cpu/memory

When the socket error occurred, the SDK output as following, there’s a 3s delay between link sender state changed and exception throw

10/27/2023 5:58:02 AM | Executing ‘Functions.enqueueData1’ (Reason=‘This function was programmatically called via the host APIs.’, Id=2f0b2079-75b7-4345-907e-90256c4fde97) 10/27/2023 5:58:02 AM | Python HTTP trigger function processed a request. 10/27/2023 5:58:02 AM | Message validation begins 10/27/2023 5:58:02 AM | Message validation completed 10/27/2023 5:58:02 AM | Sending message 10/27/2023 5:58:02 AM | Session state changed: <SessionState.UNMAPPED: 0> -> <SessionState.END_SENT: 4> 10/27/2023 5:58:02 AM | An error occurred when closing the connection: AMQPConnectionError(‘Error condition: ErrorCondition.SocketError\n Error Description: Can not send frame out due to exception: [Errno 104] Connection reset by peer’) 10/27/2023 5:58:02 AM | Connection state changed: <ConnectionState.OPENED: 9> -> <ConnectionState.END: 13> 10/27/2023 5:58:02 AM | Connection state changed: None -> <ConnectionState.START: 0> 10/27/2023 5:58:02 AM | Connection state changed: <ConnectionState.START: 0> -> <ConnectionState.HDR_SENT: 2> 10/27/2023 5:58:02 AM | Connection state changed: <ConnectionState.HDR_SENT: 2> -> <ConnectionState.HDR_SENT: 2> 10/27/2023 5:58:02 AM | Connection state changed: <ConnectionState.HDR_SENT: 2> -> <ConnectionState.OPEN_PIPE: 4> 10/27/2023 5:58:02 AM | Session state changed: <SessionState.UNMAPPED: 0> -> <SessionState.BEGIN_SENT: 1> 10/27/2023 5:58:02 AM | Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1> 10/27/2023 5:58:02 AM | Management link receiver state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1> 10/27/2023 5:58:02 AM | Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1> 10/27/2023 5:58:02 AM | Management link sender state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1> 10/27/2023 5:58:02 AM | Connection state changed: <ConnectionState.OPEN_PIPE: 4> -> <ConnectionState.OPEN_SENT: 7> 10/27/2023 5:58:02 AM | Connection state changed: <ConnectionState.OPEN_SENT: 7> -> <ConnectionState.OPENED: 9> 10/27/2023 5:58:02 AM | Session state changed: <SessionState.BEGIN_SENT: 1> -> <SessionState.MAPPED: 3> 10/27/2023 5:58:02 AM | Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3> 10/27/2023 5:58:02 AM | Management link receiver state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3> 10/27/2023 5:58:02 AM | Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3> 10/27/2023 5:58:02 AM | Management link sender state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3> 10/27/2023 5:58:05 AM | AMQP error occurred: (AMQPLinkError(“Error condition: amqp🔗detach-forced\n Error Description: The link ‘G20:104524099:6f059c89-6e30-4486-9be2-37f33cd4d84a’ is force detached. Code: publisher(link65173734). Details: AmqpMessagePublisher.IdleTimerExpired: Idle timeout: 00:10:00.”)), condition: (b’amqp🔗detach-forced’), description: (b"The link ‘G20:104524099:6f059c89-6e30-4486-9be2-37f33cd4d84a’ is force detached. Code: publisher(link65173734). Details: AmqpMessagePublisher.IdleTimerExpired: Idle timeout: 00:10:00."). 10/27/2023 5:58:05 AM | Link state changed: <LinkState.ATTACHED: 3> -> <LinkState.DETACH_SENT: 4> 10/27/2023 5:58:05 AM | Link state changed: <LinkState.ATTACHED: 3> -> <LinkState.DETACH_SENT: 4> 10/27/2023 5:58:05 AM | Management link sender state changed: <LinkState.ATTACHED: 3> -> <LinkState.DETACH_SENT: 4> 10/27/2023 5:58:05 AM | Session state changed: <SessionState.MAPPED: 3> -> <SessionState.END_SENT: 4> 10/27/2023 5:58:05 AM | Connection state changed: <ConnectionState.OPENED: 9> -> <ConnectionState.CLOSE_SENT: 11> 10/27/2023 5:58:05 AM | Management link receiver state changed: <LinkState.ATTACHED: 3> -> <LinkState.DETACH_SENT: 4> 10/27/2023 5:58:05 AM | Connection state changed: <ConnectionState.CLOSE_SENT: 11> -> <ConnectionState.END: 13> 10/27/2023 5:58:05 AM | Session state changed: <SessionState.END_SENT: 4> -> <SessionState.DISCARDING: 6> 10/27/2023 5:58:05 AM | Link state changed: <LinkState.DETACH_SENT: 4> -> <LinkState.DETACHED: 0> 10/27/2023 5:58:05 AM | Management link sender state changed: <LinkState.DETACH_SENT: 4> -> <LinkState.DETACHED: 0> 10/27/2023 5:58:05 AM | Link state changed: <LinkState.DETACH_SENT: 4> -> <LinkState.DETACHED: 0> 10/27/2023 5:58:05 AM | Management link receiver state changed: <LinkState.DETACH_SENT: 4> -> <LinkState.DETACHED: 0> 10/27/2023 5:58:06 AM | ‘servicebus.pysdk-ad8e5bf4’ has an exception (ServiceBusConnectionError(“The link ‘G20:104524099:6f059c89-6e30-4486-9be2-37f33cd4d84a’ is force detached. Code: publisher(link65173734). Details: AmqpMessagePublisher.IdleTimerExpired: Idle timeout: 00:10:00. Error condition: amqp🔗detach-forced.”)). Retrying… 10/27/2023 5:58:06 AM | Connection state changed: None -> <ConnectionState.START: 0> 10/27/2023 5:58:06 AM | Connection state changed: <ConnectionState.START: 0> -> <ConnectionState.HDR_SENT: 2> 10/27/2023 5:58:06 AM | Connection state changed: <ConnectionState.HDR_SENT: 2> -> <ConnectionState.OPEN_PIPE: 4> 10/27/2023 5:58:06 AM | Session state changed: <SessionState.UNMAPPED: 0> -> <SessionState.BEGIN_SENT: 1> 10/27/2023 5:58:06 AM | Connection state changed: <ConnectionState.HDR_SENT: 2> -> <ConnectionState.HDR_SENT: 2> 10/27/2023 5:58:06 AM | Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1> 10/27/2023 5:58:06 AM | Management link receiver state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1> 10/27/2023 5:58:06 AM | Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1> 10/27/2023 5:58:06 AM | Management link sender state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1> 10/27/2023 5:58:06 AM | Connection state changed: <ConnectionState.OPEN_PIPE: 4> -> <ConnectionState.OPEN_SENT: 7> 10/27/2023 5:58:06 AM | Connection state changed: <ConnectionState.OPEN_SENT: 7> -> <ConnectionState.OPENED: 9> 10/27/2023 5:58:06 AM | Session state changed: <SessionState.BEGIN_SENT: 1> -> <SessionState.MAPPED: 3> 10/27/2023 5:58:06 AM | Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3> 10/27/2023 5:58:06 AM | Management link receiver state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3> 10/27/2023 5:58:06 AM | Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3> 10/27/2023 5:58:06 AM | Management link sender state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3> 10/27/2023 5:58:07 AM | Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1> 10/27/2023 5:58:07 AM | Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3> 10/27/2023 5:58:07 AM | Message sent successfully 10/27/2023 5:58:07 AM | Executed ‘Functions.enqueueData1’ (Succeeded, Id=2f0b2079-75b7-4345-907e-90256c4fde97, Duration=5085ms)

  1. found a smilar github bug Async Eventhub Consumer with Pyamqp: Link Detached after long idle period Results in High “User Errors” volume · Issue #28996 · Azure/azure-sdk-for-python · GitHub

  2. support ticket opened 2310260030004667

To Reproduce Steps to reproduce the behavior:

  1. code we are using `---------------------------------------------------------------------------------- shared code

def get_service_bus_queue_sender(self, conn, queue): client = ServiceBusClient.from_connection_string(conn, retry_mode= “exponential” , retry_backoff_factor= 0.5) logging.info(“Service bus sender initializing”) sender = client.get_queue_sender(queue) logging.info(“Service bus sender initialization completed”) return sender


Application code

import os import sys import json import azure.functions as func import logging from Common.shared_code.error_response_helper import ErrorResponse from azure.servicebus import ServiceBusMessage from datetime import timezone import datetime as dt from Common.shared_code.shared import Shared, Trace

msg_expiry_time = os.environ[‘MSG_EXPIRY_TIME_IN_HOURS’]

from pathlib import Path script_location = Path(file).absolute().parents[1]

sender = None sender_001= None sender_002= None sender_003= None sender_004= None sender_005= None sender_006= None sender_007= None sender_008= None

class Enqueue: “”" Enqueue class to get json output"“” def init(self): self.error = None global sender global sender_001 global sender_002 global sender_003 global sender_004 global sender_005 global sender_006 global sender_007 global sender_008

    self.__queue_001 = "ellipsefoundation001"
    self.__queue_002 = "ellipsefoundation002"
    self.__queue_003 = "ellipsefoundation003"
    self.__queue_004 = "ellipsefoundation004"
    self.__queue_005 = "ellipsefoundation005"
    self.__queue_006 = "ellipsefoundation006"
    self.__queue_007 = "ellipsefoundation007"
    self.__queue_008 = "ellipsefoundation008"

    self.__api_name = "enqueueData1"

    self.__is_valid = True
    
    if sender_001 is None:
        sender_001 = Shared().get_service_bus_queue_sender(os.environ["SERVICE_BUS_CONNECTION_STR_ellipsefoundation001"], self.__queue_001)
    
    if sender_002 is None:
        sender_002 = Shared().get_service_bus_queue_sender(os.environ["SERVICE_BUS_CONNECTION_STR_ellipsefoundation002"], self.__queue_002)
    
    if sender_003 is None:
        sender_003 = Shared().get_service_bus_queue_sender(os.environ["SERVICE_BUS_CONNECTION_STR_ellipsefoundation003"], self.__queue_003)

    if sender_004 is None:
        sender_004 = Shared().get_service_bus_queue_sender(os.environ["SERVICE_BUS_CONNECTION_STR_ellipsefoundation004"], self.__queue_004)

    if sender_005 is None:
        sender_005 = Shared().get_service_bus_queue_sender(os.environ["SERVICE_BUS_CONNECTION_STR_ellipsefoundation005"], self.__queue_005)

    if sender_006 is None:
        sender_006 = Shared().get_service_bus_queue_sender(os.environ["SERVICE_BUS_CONNECTION_STR_ellipsefoundation006"], self.__queue_006)

    if sender_007 is None:
        sender_007 = Shared().get_service_bus_queue_sender(os.environ["SERVICE_BUS_CONNECTION_STR_ellipsefoundation007"], self.__queue_007)

    if sender_008 is None:
        sender_008 = Shared().get_service_bus_queue_sender(os.environ["SERVICE_BUS_CONNECTION_STR_ellipsefoundation008"], self.__queue_008)

def push_data(self, input_json):
    """ function which send output response """

    try:
        req_data = json.loads(input_json)

        # Validating the request payload
        schema = script_location /'enqueueData'/'request_payload_schema.json'
        with open(schema) as f:
            schema = json.load(f)
        logging.info("Message validation begins")
        self.__is_valid = Shared().validate_json(req_data, schema)
        logging.info("Message validation completed")

        if self.__is_valid[0]:
            configured_tables = list(dict(os.environ).keys())
            table = req_data["control"]["table"]

            if table in configured_tables:
                table_config = os.environ[table]
            else:
                table_config = os.environ["ELLIPSE_TABLES"]

            queue_name = table_config
            session_id = table

            correlation_id = req_data["messageContext"]["correlationId"]
            message_id = req_data["messageContext"]["messageId"]

            if queue_name == self.__queue_001:
                sender = sender_001
            elif queue_name == self.__queue_002:
                sender = sender_002
            elif queue_name == self.__queue_003:
                sender = sender_003
            elif queue_name == self.__queue_004:
                sender = sender_004
            elif queue_name == self.__queue_005:
                sender = sender_005
            elif queue_name == self.__queue_006:
                sender = sender_006
            elif queue_name == self.__queue_007:
                sender = sender_007
            elif queue_name == self.__queue_008:
                sender = sender_008

            current_time = dt.datetime.utcnow()
            current_time = current_time.replace(tzinfo=timezone(dt.timedelta(hours= 0), name="GMT"))
            insertion_time = current_time.strftime(f"%A, %d %b %Y %H:%M:%S %Z")
            expiry_time = current_time + dt.timedelta(hours= int(msg_expiry_time))
            expiry_time = expiry_time.strftime(f"%A, %d %b %Y %H:%M:%S %Z")

            logging.info("Sending message")
            sender.send_messages(ServiceBusMessage(input_json, session_id=session_id, correlation_id=correlation_id, message_id= message_id, content_type='application/json', time_to_live= dt.timedelta(hours= int(msg_expiry_time))))
            logging.info("Message sent successfully")

            response_file = script_location /'enqueueData'/'sample_response.json'
            with open(response_file) as f:
                response = json.load(f)
            response["queue"]["queueName"] = queue_name
            response["queue"]["queueMessagesList"][0]["queueMessage"]["messageId"] = message_id
            response["queue"]["queueMessagesList"][0]["queueMessage"]["insertionTime"] = insertion_time
            response["queue"]["queueMessagesList"][0]["queueMessage"]["expirationTime"] = expiry_time
            response =json.dumps(response)
            Trace().trace_attributes(self.__api_name, message_id, table, queue_name)
            return func.HttpResponse(response, status_code=201, mimetype = 'application/json; charset=utf8') 
        else:
            self.error = self.__is_valid[1]
            error_json = {
                        "message": self.error.message,
                        "path":  self.error.json_path
                        }
            error_json = json.dumps(error_json)
            return func.HttpResponse(error_json, status_code=400)
            
    except Exception:
        retmsg = 'Error - Error Info :' +  str(sys.exc_info()) 
        logging.error(f"{retmsg}")
        return ErrorResponse().error_log('Internal Server Error',500)  `

Expected behavior when there’s link detach error, the retry should soon success without 3s interval.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

About this issue

  • Original URL
  • State: open
  • Created 8 months ago
  • Comments: 24 (8 by maintainers)

Most upvoted comments

Hi @swathipil thanks for the reply, the log is all SDK activities and it is similar to the previous debug log we provided, it seems that when there was idle connection exception, the SDK has some logic spend 3s up to 2 mins to perform retry, 3s is acceptable but 2mins is too long waiting for an exception to retry, could you provide any possiable cause for this or is there any logic/configuration we can try to reduce this time

TimeGenerated Message
1/8/2024 10:33:34 PM Executing ‘Functions.enqueueData3’ (Reason=‘This function was programmatically called via the host APIs.’, Id=47c66bb1-2691-4265-a7d8-21fc686f3e6d)
1/8/2024 10:33:34 PM Python HTTP trigger function processed a request.
1/8/2024 10:33:34 PM Message validation begins
1/8/2024 10:33:34 PM Message validation completed
1/8/2024 10:33:34 PM Sending message
1/8/2024 10:33:34 PM Link state changed: <LinkState.ATTACHED: 3> -> <LinkState.DETACHED: 0>
1/8/2024 10:33:34 PM Management link receiver state changed: <LinkState.ATTACHED: 3> -> <LinkState.DETACHED: 0>
1/8/2024 10:33:34 PM CBS error occurred.
1/8/2024 10:33:34 PM Link state changed: <LinkState.ATTACHED: 3> -> <LinkState.DETACHED: 0>
1/8/2024 10:33:34 PM Management link sender state changed: <LinkState.ATTACHED: 3> -> <LinkState.DETACHED: 0>
1/8/2024 10:33:34 PM Link state changed: <LinkState.ATTACHED: 3> -> <LinkState.DETACHED: 0>
1/8/2024 10:33:34 PM Session state changed: <SessionState.MAPPED: 3> -> <SessionState.END_RCVD: 5>
1/8/2024 10:33:34 PM Session state changed: <SessionState.END_RCVD: 5> -> <SessionState.UNMAPPED: 0>
1/8/2024 10:33:34 PM Connection state changed: <ConnectionState.OPENED: 9> -> <ConnectionState.CLOSE_RCVD: 10>
1/8/2024 10:33:34 PM Connection state changed: <ConnectionState.CLOSE_RCVD: 10> -> <ConnectionState.END: 13>
1/8/2024 10:33:35 PM Session state changed: <SessionState.UNMAPPED: 0> -> <SessionState.END_SENT: 4>
1/8/2024 10:33:36 PM Connection state changed: None -> <ConnectionState.START: 0>
1/8/2024 10:33:36 PM Connection state changed: <ConnectionState.START: 0> -> <ConnectionState.HDR_SENT: 2>
1/8/2024 10:33:36 PM Connection state changed: <ConnectionState.HDR_SENT: 2> -> <ConnectionState.HDR_SENT: 2>
1/8/2024 10:33:36 PM Connection state changed: <ConnectionState.HDR_SENT: 2> -> <ConnectionState.OPEN_PIPE: 4>
1/8/2024 10:33:36 PM Session state changed: <SessionState.UNMAPPED: 0> -> <SessionState.BEGIN_SENT: 1>
1/8/2024 10:33:36 PM Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
1/8/2024 10:33:36 PM Management link receiver state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
1/8/2024 10:33:36 PM Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
1/8/2024 10:33:36 PM Management link sender state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
1/8/2024 10:33:36 PM Connection state changed: <ConnectionState.OPEN_PIPE: 4> -> <ConnectionState.OPEN_SENT: 7>
1/8/2024 10:33:36 PM Connection state changed: <ConnectionState.OPEN_SENT: 7> -> <ConnectionState.OPENED: 9>
1/8/2024 10:33:36 PM Session state changed: <SessionState.BEGIN_SENT: 1> -> <SessionState.MAPPED: 3>
1/8/2024 10:33:36 PM Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
1/8/2024 10:33:36 PM Management link receiver state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
1/8/2024 10:33:36 PM Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
1/8/2024 10:33:36 PM Management link sender state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
1/8/2024 10:34:36 PM Link state changed: <LinkState.ATTACHED: 3> -> <LinkState.ERROR: 6>
1/8/2024 10:34:36 PM Management link receiver state changed: <LinkState.ATTACHED: 3> -> <LinkState.ERROR: 6>
1/8/2024 10:34:36 PM CBS error occurred.
1/8/2024 10:34:36 PM Link state changed: <LinkState.ATTACHED: 3> -> <LinkState.ERROR: 6>
1/8/2024 10:34:36 PM Management link sender state changed: <LinkState.ATTACHED: 3> -> <LinkState.ERROR: 6>
1/8/2024 10:34:36 PM Session state changed: <SessionState.MAPPED: 3> -> <SessionState.END_RCVD: 5>
1/8/2024 10:34:36 PM Session state changed: <SessionState.END_RCVD: 5> -> <SessionState.UNMAPPED: 0>
1/8/2024 10:34:36 PM Connection state changed: <ConnectionState.OPENED: 9> -> <ConnectionState.CLOSE_RCVD: 10>
1/8/2024 10:34:36 PM Connection state changed: <ConnectionState.CLOSE_RCVD: 10> -> <ConnectionState.END: 13>
1/8/2024 10:34:36 PM Connection closed with error: [b’amqp:connection:forced’, b"The connection was inactive for more than the allowed 60000 milliseconds and is closed by container ‘LinkTracker’. TrackingId:15421d8e36ac469c94a85aaa16f38123_G5, SystemTracker:gateway7, Timestamp:2024-01-08T22:34:36", None]
1/8/2024 10:34:38 PM Session state changed: <SessionState.UNMAPPED: 0> -> <SessionState.END_SENT: 4>
1/8/2024 10:34:38 PM Connection state changed: None -> <ConnectionState.START: 0>
1/8/2024 10:34:38 PM Connection state changed: <ConnectionState.START: 0> -> <ConnectionState.HDR_SENT: 2>
1/8/2024 10:34:38 PM Connection state changed: <ConnectionState.HDR_SENT: 2> -> <ConnectionState.HDR_SENT: 2>
1/8/2024 10:34:38 PM Connection state changed: <ConnectionState.HDR_SENT: 2> -> <ConnectionState.OPEN_PIPE: 4>
1/8/2024 10:34:38 PM Session state changed: <SessionState.UNMAPPED: 0> -> <SessionState.BEGIN_SENT: 1>
1/8/2024 10:34:38 PM Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
1/8/2024 10:34:38 PM Management link receiver state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
1/8/2024 10:34:38 PM Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
1/8/2024 10:34:38 PM Management link sender state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
1/8/2024 10:34:38 PM Connection state changed: <ConnectionState.OPEN_PIPE: 4> -> <ConnectionState.OPEN_SENT: 7>
1/8/2024 10:34:38 PM Connection state changed: <ConnectionState.OPEN_SENT: 7> -> <ConnectionState.OPENED: 9>
1/8/2024 10:34:38 PM Session state changed: <SessionState.BEGIN_SENT: 1> -> <SessionState.MAPPED: 3>
1/8/2024 10:34:38 PM Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
1/8/2024 10:34:38 PM Management link receiver state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
1/8/2024 10:34:38 PM Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
1/8/2024 10:34:38 PM Management link sender state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
1/8/2024 10:35:38 PM Link state changed: <LinkState.ATTACHED: 3> -> <LinkState.ERROR: 6>
1/8/2024 10:35:38 PM Management link receiver state changed: <LinkState.ATTACHED: 3> -> <LinkState.ERROR: 6>
1/8/2024 10:35:38 PM CBS error occurred.
1/8/2024 10:35:38 PM Link state changed: <LinkState.ATTACHED: 3> -> <LinkState.ERROR: 6>
1/8/2024 10:35:38 PM Management link sender state changed: <LinkState.ATTACHED: 3> -> <LinkState.ERROR: 6>
1/8/2024 10:35:38 PM Session state changed: <SessionState.MAPPED: 3> -> <SessionState.END_RCVD: 5>
1/8/2024 10:35:38 PM Session state changed: <SessionState.END_RCVD: 5> -> <SessionState.UNMAPPED: 0>
1/8/2024 10:35:38 PM Connection state changed: <ConnectionState.OPENED: 9> -> <ConnectionState.CLOSE_RCVD: 10>
1/8/2024 10:35:38 PM Connection state changed: <ConnectionState.CLOSE_RCVD: 10> -> <ConnectionState.END: 13>
1/8/2024 10:35:38 PM Connection closed with error: [b’amqp:connection:forced’, b"The connection was inactive for more than the allowed 60000 milliseconds and is closed by container ‘LinkTracker’. TrackingId:08a9f492ba0e4725b7c3ab861a1ff8bf_G80, SystemTracker:gateway7, Timestamp:2024-01-08T22:35:38", None]
1/8/2024 10:35:38 PM AMQP error occurred: (AMQPConnectionError(“Error condition: amqp:connection:forced\n Error Description: The connection was inactive for more than the allowed 60000 milliseconds and is closed by container ‘LinkTracker’. TrackingId:08a9f492ba0e4725b7c3ab861a1ff8bf_G80, SystemTracker:gateway7, Timestamp:2024-01-08T22:35:38”)), condition: (b’amqp:connection:forced’), description: (b"The connection was inactive for more than the allowed 60000 milliseconds and is closed by container ‘LinkTracker’. TrackingId:08a9f492ba0e4725b7c3ab861a1ff8bf_G80, SystemTracker:gateway7, Timestamp:2024-01-08T22:35:38").
1/8/2024 10:35:38 PM Session state changed: <SessionState.UNMAPPED: 0> -> <SessionState.END_SENT: 4>
1/8/2024 10:35:39 PM ‘servicebus.pysdk-cccda0f9’ has an exception (ServiceBusConnectionError(“The connection was inactive for more than the allowed 60000 milliseconds and is closed by container ‘LinkTracker’. TrackingId:08a9f492ba0e4725b7c3ab861a1ff8bf_G80, SystemTracker:gateway7, Timestamp:2024-01-08T22:35:38 Error condition: amqp:connection:forced.”)). Retrying…
1/8/2024 10:35:39 PM Connection state changed: None -> <ConnectionState.START: 0>
1/8/2024 10:35:39 PM Connection state changed: <ConnectionState.START: 0> -> <ConnectionState.HDR_SENT: 2>
1/8/2024 10:35:39 PM Connection state changed: <ConnectionState.HDR_SENT: 2> -> <ConnectionState.HDR_SENT: 2>
1/8/2024 10:35:39 PM Connection state changed: <ConnectionState.HDR_SENT: 2> -> <ConnectionState.OPEN_PIPE: 4>
1/8/2024 10:35:39 PM Session state changed: <SessionState.UNMAPPED: 0> -> <SessionState.BEGIN_SENT: 1>
1/8/2024 10:35:39 PM Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
1/8/2024 10:35:39 PM Management link receiver state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
1/8/2024 10:35:39 PM Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
1/8/2024 10:35:39 PM Management link sender state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
1/8/2024 10:35:39 PM Connection state changed: <ConnectionState.OPEN_PIPE: 4> -> <ConnectionState.OPEN_SENT: 7>
1/8/2024 10:35:39 PM Connection state changed: <ConnectionState.OPEN_SENT: 7> -> <ConnectionState.OPENED: 9>
1/8/2024 10:35:39 PM Session state changed: <SessionState.BEGIN_SENT: 1> -> <SessionState.MAPPED: 3>
1/8/2024 10:35:40 PM Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
1/8/2024 10:35:40 PM Management link receiver state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
1/8/2024 10:35:40 PM Management link sender state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
1/8/2024 10:35:40 PM Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
1/8/2024 10:35:40 PM Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
1/8/2024 10:35:40 PM Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
1/8/2024 10:35:40 PM Message sent successfully
1/8/2024 10:35:40 PM Executed ‘Functions.enqueueData3’ (Succeeded, Id=47c66bb1-2691-4265-a7d8-21fc686f3e6d, Duration=125593ms)

Hi @kashifkhan Im able to reproduce it with following code snippet

from azure.servicebus import ServiceBusClient, ServiceBusMessage
import logging
import sys

logger = logging.getLogger('azure.servicebus')
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler(stream=sys.stdout)
formatter = logging.Formatter("%(asctime)s;%(levelname)s;%(message)s")
handler.setFormatter(formatter)
logger.addHandler(handler)

connection_string = "xxxxxxxxxxx"

queue = "xxxxxxx"

servicebus_client = ServiceBusClient.from_connection_string(conn_str=connection_string,  logging_enable=True)
sender = servicebus_client.get_queue_sender(queue)
single_message = ServiceBusMessage("Single message")
sender.send_messages(single_message)

# wait for 10 minutes till link detaches then send one more message

sender.send_messages(single_message)

Here are my debug logs

2023-11-16 17:20:28,924;INFO;Connection state changed: None -> <ConnectionState.START: 0>
2023-11-16 17:20:28,926;DEBUG;-> Header(b'AMQP\x00\x01\x00\x00')
2023-11-16 17:20:28,926;INFO;Connection state changed: <ConnectionState.START: 0> -> <ConnectionState.HDR_SENT: 2>
2023-11-16 17:20:28,926;INFO;Connection state changed: <ConnectionState.HDR_SENT: 2> -> <ConnectionState.HDR_SENT: 2>
2023-11-16 17:20:28,926;DEBUG;-> OpenFrame(container_id='SBSender-f6a89c8f-39a1-48ee-b5b5-54824c2e5b1c', hostname='commons-workers.servicebus.windows.net', max_frame_size=1048576, channel_max=65535, idle_timeout=None, outgoing_locales=None, incoming_locales=None, offered_capabilities=None, desired_capabilities=None, properties={'product': 'azsdk-python-servicebus', 'version': '7.11.4', 'framework': 'Python/3.9.5', 'platform': 'Linux-5.15.0-1037-azure-x86_64-with-glibc2.31', 'user-agent': 'azsdk-python-servicebus/7.11.4 pyamqp/2.0.0a1 Python/3.9.5 (Linux-5.15.0-1037-azure-x86_64-with-glibc2.31)'})
2023-11-16 17:20:28,927;INFO;Connection state changed: <ConnectionState.HDR_SENT: 2> -> <ConnectionState.OPEN_PIPE: 4>
2023-11-16 17:20:28,927;DEBUG;-> BeginFrame(remote_channel=None, next_outgoing_id=0, incoming_window=65536, outgoing_window=65536, handle_max=4294967295, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:20:28,927;INFO;Session state changed: <SessionState.UNMAPPED: 0> -> <SessionState.BEGIN_SENT: 1>
2023-11-16 17:20:28,928;DEBUG;-> AttachFrame(name='639b1d9f-5283-405b-abb4-56a8f3edd176', handle=2, role=True, send_settle_mode=0, rcv_settle_mode=0, source=Source(address='$cbs', durable=None, expiry_policy=None, timeout=None, dynamic=None, dynamic_node_properties=None, distribution_mode=None, filters=None, default_outcome=None, outcomes=None, capabilities=None), target=Target(address='$cbs', durable=None, expiry_policy=None, timeout=None, dynamic=None, dynamic_node_properties=None, capabilities=None), unsettled=None, incomplete_unsettled=None, initial_delivery_count=None, max_message_size=None, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:20:28,928;INFO;Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
2023-11-16 17:20:28,928;INFO;Management link receiver state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
2023-11-16 17:20:28,928;DEBUG;-> AttachFrame(name='746858f6-1c34-4cff-97bc-8e095119c32f', handle=1, role=False, send_settle_mode=0, rcv_settle_mode=0, source=Source(address='$cbs', durable=None, expiry_policy=None, timeout=None, dynamic=None, dynamic_node_properties=None, distribution_mode=None, filters=None, default_outcome=None, outcomes=None, capabilities=None), target=Target(address='$cbs', durable=None, expiry_policy=None, timeout=None, dynamic=None, dynamic_node_properties=None, capabilities=None), unsettled=None, incomplete_unsettled=None, initial_delivery_count=0, max_message_size=None, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:20:28,929;INFO;Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
2023-11-16 17:20:28,929;INFO;Management link sender state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
2023-11-16 17:20:28,929;DEBUG;<- Header(b'AMQP\x00\x01\x00\x00')
2023-11-16 17:20:28,929;INFO;Connection state changed: <ConnectionState.OPEN_PIPE: 4> -> <ConnectionState.OPEN_SENT: 7>
2023-11-16 17:20:28,979;DEBUG;<- OpenFrame(container_id=b'f0afceeb6e9e415193d3728ebf96f6ea_G20', hostname=None, max_frame_size=65536, channel_max=4999, idle_timeout=120000, outgoing_locales=None, incoming_locales=None, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:20:28,980;INFO;Connection state changed: <ConnectionState.OPEN_SENT: 7> -> <ConnectionState.OPENED: 9>
2023-11-16 17:20:29,030;DEBUG;<- BeginFrame(remote_channel=1, next_outgoing_id=1, incoming_window=5000, outgoing_window=65536, handle_max=255, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:20:29,030;INFO;Session state changed: <SessionState.BEGIN_SENT: 1> -> <SessionState.MAPPED: 3>
2023-11-16 17:20:29,081;DEBUG;<- AttachFrame(name=b'639b1d9f-5283-405b-abb4-56a8f3edd176', handle=0, role=False, send_settle_mode=0, rcv_settle_mode=0, source=[b'$cbs', None, None, None, None, None, None, None, None, None, None], target=[b'$cbs', None, None, None, None, None, None], unsettled=None, incomplete_unsettled=None, initial_delivery_count=0, max_message_size=18446744073709551615, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:20:29,081;INFO;Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
2023-11-16 17:20:29,081;INFO;Management link receiver state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
2023-11-16 17:20:29,081;DEBUG;-> FlowFrame(next_incoming_id=1, incoming_window=65536, next_outgoing_id=0, outgoing_window=65536, handle=2, delivery_count=0, link_credit=10000, available=None, drain=None, echo=None, properties=None)
2023-11-16 17:20:29,132;DEBUG;<- AttachFrame(name=b'746858f6-1c34-4cff-97bc-8e095119c32f', handle=1, role=True, send_settle_mode=0, rcv_settle_mode=0, source=[b'$cbs', None, None, None, None, None, None, None, None, None, None], target=[b'$cbs', None, None, None, None, None, None], unsettled=None, incomplete_unsettled=None, initial_delivery_count=None, max_message_size=18446744073709551615, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:20:29,132;INFO;Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
2023-11-16 17:20:29,133;INFO;Management link sender state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
2023-11-16 17:20:29,133;DEBUG;CBS completed opening with status: <ManagementOpenResult.OK: 1>
2023-11-16 17:20:29,133;DEBUG;-> FlowFrame(next_incoming_id=1, incoming_window=65536, next_outgoing_id=0, outgoing_window=65536, handle=1, delivery_count=0, link_credit=10000, available=None, drain=None, echo=None, properties=None)
2023-11-16 17:20:29,184;DEBUG;-> TransferFrame(handle=1, delivery_id=0, delivery_tag=b'\x00\x00\x00\x01', message_format=0, settled=False, more=False, rcv_settle_mode=None, state=None, resume=None, aborted=None, batchable=None, payload=b'***')
2023-11-16 17:20:29,185;DEBUG;<- FlowFrame(next_incoming_id=0, incoming_window=5000, next_outgoing_id=1, outgoing_window=65536, handle=1, delivery_count=0, link_credit=100, available=0, drain=None, echo=False, properties=None)
2023-11-16 17:20:29,235;DEBUG;CBS update in progress. Token put time: 1700155229
2023-11-16 17:20:29,235;DEBUG;<- DispositionFrame(role=True, first=0, last=None, settled=True, state={'accepted': []}, batchable=None)
2023-11-16 17:20:29,286;DEBUG;CBS update in progress. Token put time: 1700155229
2023-11-16 17:20:29,286;DEBUG;<- TransferFrame(handle=0, delivery_id=0, delivery_tag=b'\x01\x00\x00\x00', message_format=0, settled=None, more=False, rcv_settle_mode=None, state=None, resume=None, aborted=None, batchable=False, payload=b'***')
2023-11-16 17:20:29,286;DEBUG;CBS Put token result (<ManagementExecuteOperationResult.OK: 0>), status code: 202, status_description: b'Accepted'.
2023-11-16 17:20:29,337;DEBUG;CBS status check: state == <CbsAuthState.OK: 0>, expired == False, refresh required == False
2023-11-16 17:20:29,337;DEBUG;-> AttachFrame(name='4ba3edc0-5f93-44d3-bfd7-ef40a6e3ddf6', handle=3, role=False, send_settle_mode=0, rcv_settle_mode=1, source=Source(address='sender-link-4ba3edc0-5f93-44d3-bfd7-ef40a6e3ddf6', durable=None, expiry_policy=None, timeout=None, dynamic=None, dynamic_node_properties=None, distribution_mode=None, filters=None, default_outcome=None, outcomes=None, capabilities=None), target=Target(address='amqps://commons-workers.servicebus.windows.net/t_queue', durable=None, expiry_policy=None, timeout=None, dynamic=None, dynamic_node_properties=None, capabilities=None), unsettled=None, incomplete_unsettled=None, initial_delivery_count=0, max_message_size=1048576, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:20:29,338;INFO;Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
2023-11-16 17:20:29,341;DEBUG;<- AttachFrame(name=b'4ba3edc0-5f93-44d3-bfd7-ef40a6e3ddf6', handle=2, role=True, send_settle_mode=0, rcv_settle_mode=0, source=[b'sender-link-4ba3edc0-5f93-44d3-bfd7-ef40a6e3ddf6', None, None, None, None, None, None, None, None, None, None], target=[b'amqps://commons-workers.servicebus.windows.net/t_queue', None, None, None, None, None, None], unsettled=None, incomplete_unsettled=None, initial_delivery_count=None, max_message_size=262144, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:20:29,341;INFO;Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
2023-11-16 17:20:29,341;DEBUG;-> FlowFrame(next_incoming_id=2, incoming_window=65535, next_outgoing_id=1, outgoing_window=65535, handle=3, delivery_count=0, link_credit=10000, available=None, drain=None, echo=None, properties=None)
2023-11-16 17:20:29,391;DEBUG;CBS status check: state == <CbsAuthState.OK: 0>, expired == False, refresh required == False
2023-11-16 17:20:29,392;DEBUG;CBS status check: state == <CbsAuthState.OK: 0>, expired == False, refresh required == False
2023-11-16 17:20:29,392;DEBUG;CBS status check: state == <CbsAuthState.OK: 0>, expired == False, refresh required == False
2023-11-16 17:20:29,392;DEBUG;-> TransferFrame(handle=3, delivery_id=1, delivery_tag=b'\x00\x00\x00\x01', message_format=0, settled=False, more=False, rcv_settle_mode=None, state=None, resume=None, aborted=None, batchable=None, payload=b'***')
2023-11-16 17:20:29,393;DEBUG;<- FlowFrame(next_incoming_id=1, incoming_window=5000, next_outgoing_id=2, outgoing_window=65535, handle=2, delivery_count=0, link_credit=1000, available=0, drain=None, echo=False, properties=None)
2023-11-16 17:20:29,393;DEBUG;CBS status check: state == <CbsAuthState.OK: 0>, expired == False, refresh required == False
2023-11-16 17:20:29,403;DEBUG;<- DispositionFrame(role=True, first=1, last=None, settled=True, state={'accepted': []}, batchable=None)

In [2]: 2023-11-16 17:20:58,960;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:21:29,195;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:21:29,195;DEBUG;<- DispositionFrame(role=False, first=0, last=None, settled=True, state={'released': []}, batchable=None)
2023-11-16 17:21:59,429;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:21:59,429;DEBUG;-> EmptyFrame()
2023-11-16 17:22:29,664;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:22:59,899;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:22:59,899;DEBUG;-> EmptyFrame()
2023-11-16 17:23:30,133;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:23:30,133;DEBUG;<- FlowFrame(next_incoming_id=2, incoming_window=5000, next_outgoing_id=2, outgoing_window=65535, handle=None, delivery_count=None, link_credit=None, available=None, drain=None, echo=True, properties=None)
2023-11-16 17:24:00,367;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:24:00,367;DEBUG;-> EmptyFrame()
2023-11-16 17:24:30,602;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:25:00,836;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:25:00,836;DEBUG;-> EmptyFrame()
2023-11-16 17:25:31,071;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:26:01,306;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:26:01,306;DEBUG;-> EmptyFrame()
2023-11-16 17:26:31,540;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:26:31,541;DEBUG;<- FlowFrame(next_incoming_id=2, incoming_window=5000, next_outgoing_id=2, outgoing_window=65535, handle=None, delivery_count=None, link_credit=None, available=None, drain=None, echo=True, properties=None)
2023-11-16 17:27:01,775;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:27:01,775;DEBUG;-> EmptyFrame()
2023-11-16 17:27:32,009;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:28:02,242;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:28:02,242;DEBUG;-> EmptyFrame()
2023-11-16 17:28:32,475;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:29:02,710;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:29:02,710;DEBUG;-> EmptyFrame()
2023-11-16 17:29:32,943;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:29:32,943;DEBUG;<- FlowFrame(next_incoming_id=2, incoming_window=5000, next_outgoing_id=2, outgoing_window=65535, handle=None, delivery_count=None, link_credit=None, available=None, drain=None, echo=True, properties=None)
2023-11-16 17:30:03,178;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:30:03,178;DEBUG;-> EmptyFrame()
2023-11-16 17:30:33,411;DEBUG;Keeping 'SendClient' connection alive.
2023-11-16 17:30:33,412;DEBUG;<- DetachFrame(handle=2, closed=True, error=[b'amqp:link:detach-forced', b"The link 'G20:678714327:4ba3edc0-5f93-44d3-bfd7-ef40a6e3ddf6' is force detached. Code: publisher(link55215490). Details: AmqpMessagePublisher.IdleTimerExpired: Idle timeout: 00:10:00.", None])
2023-11-16 17:30:33,412;DEBUG;-> DetachFrame(handle=3, closed=True, error=None)
2023-11-16 17:30:33,412;INFO;Link state changed: <LinkState.ATTACHED: 3> -> <LinkState.ERROR: 6>
In [2]:

In [2]: sender.send_messages(single_message)
2023-11-16 17:30:52,214;DEBUG;CBS status check: state == <CbsAuthState.OK: 0>, expired == False, refresh required == False
2023-11-16 17:30:52,214;DEBUG;CBS status check: state == <CbsAuthState.OK: 0>, expired == False, refresh required == False
2023-11-16 17:30:53,816;DEBUG;CBS status check: state == <CbsAuthState.OK: 0>, expired == False, refresh required == False
2023-11-16 17:30:57,020;DEBUG;CBS status check: state == <CbsAuthState.OK: 0>, expired == False, refresh required == False
2023-11-16 17:30:57,020;INFO;AMQP error occurred: (AMQPLinkError("Error condition: amqp:link:detach-forced\n Error Description: The link 'G20:678714327:4ba3edc0-5f93-44d3-bfd7-ef40a6e3ddf6' is force detached. Code: publisher(link55215490). Details: AmqpMessagePublisher.IdleTimerExpired: Idle timeout: 00:10:00.")), condition: (b'amqp:link:detach-forced'), description: (b"The link 'G20:678714327:4ba3edc0-5f93-44d3-bfd7-ef40a6e3ddf6' is force detached. Code: publisher(link55215490). Details: AmqpMessagePublisher.IdleTimerExpired: Idle timeout: 00:10:00.").
2023-11-16 17:30:57,020;DEBUG;-> DetachFrame(handle=2, closed=True, error=None)
2023-11-16 17:30:57,020;INFO;Link state changed: <LinkState.ATTACHED: 3> -> <LinkState.DETACH_SENT: 4>
2023-11-16 17:30:57,021;INFO;Management link receiver state changed: <LinkState.ATTACHED: 3> -> <LinkState.DETACH_SENT: 4>
2023-11-16 17:30:57,021;DEBUG;-> DetachFrame(handle=1, closed=True, error=None)
2023-11-16 17:30:57,021;INFO;Link state changed: <LinkState.ATTACHED: 3> -> <LinkState.DETACH_SENT: 4>
2023-11-16 17:30:57,021;INFO;Management link sender state changed: <LinkState.ATTACHED: 3> -> <LinkState.DETACH_SENT: 4>
2023-11-16 17:30:57,021;DEBUG;-> EndFrame(error=None)
2023-11-16 17:30:57,021;INFO;Session state changed: <SessionState.MAPPED: 3> -> <SessionState.END_SENT: 4>
2023-11-16 17:30:57,022;DEBUG;-> CloseFrame(error=None)
2023-11-16 17:30:57,022;INFO;Connection state changed: <ConnectionState.OPENED: 9> -> <ConnectionState.CLOSE_SENT: 11>
2023-11-16 17:30:57,022;INFO;Connection state changed: <ConnectionState.CLOSE_SENT: 11> -> <ConnectionState.END: 13>
2023-11-16 17:30:57,022;INFO;Session state changed: <SessionState.END_SENT: 4> -> <SessionState.DISCARDING: 6>
2023-11-16 17:30:57,022;INFO;Link state changed: <LinkState.DETACH_SENT: 4> -> <LinkState.DETACHED: 0>
2023-11-16 17:30:57,022;INFO;Management link sender state changed: <LinkState.DETACH_SENT: 4> -> <LinkState.DETACHED: 0>
2023-11-16 17:30:57,022;INFO;Link state changed: <LinkState.DETACH_SENT: 4> -> <LinkState.DETACHED: 0>
2023-11-16 17:30:57,022;INFO;Management link receiver state changed: <LinkState.DETACH_SENT: 4> -> <LinkState.DETACHED: 0>
2023-11-16 17:30:57,022;INFO;Link state changed: <LinkState.ERROR: 6> -> <LinkState.DETACHED: 0>
2023-11-16 17:30:59,041;INFO;'servicebus.pysdk-4e124198' has an exception (ServiceBusConnectionError("The link 'G20:678714327:4ba3edc0-5f93-44d3-bfd7-ef40a6e3ddf6' is force detached. Code: publisher(link55215490). Details: AmqpMessagePublisher.IdleTimerExpired: Idle timeout: 00:10:00. Error condition: amqp:link:detach-forced.")). Retrying...
2023-11-16 17:30:59,061;INFO;Connection state changed: None -> <ConnectionState.START: 0>
2023-11-16 17:30:59,062;DEBUG;-> Header(b'AMQP\x00\x01\x00\x00')
2023-11-16 17:30:59,062;INFO;Connection state changed: <ConnectionState.START: 0> -> <ConnectionState.HDR_SENT: 2>
2023-11-16 17:30:59,063;INFO;Connection state changed: <ConnectionState.HDR_SENT: 2> -> <ConnectionState.HDR_SENT: 2>
2023-11-16 17:30:59,063;DEBUG;-> OpenFrame(container_id='SBSender-f6a89c8f-39a1-48ee-b5b5-54824c2e5b1c', hostname='commons-workers.servicebus.windows.net', max_frame_size=1048576, channel_max=65535, idle_timeout=None, outgoing_locales=None, incoming_locales=None, offered_capabilities=None, desired_capabilities=None, properties={'product': 'azsdk-python-servicebus', 'version': '7.11.4', 'framework': 'Python/3.9.5', 'platform': 'Linux-5.15.0-1037-azure-x86_64-with-glibc2.31', 'user-agent': 'azsdk-python-servicebus/7.11.4 pyamqp/2.0.0a1 Python/3.9.5 (Linux-5.15.0-1037-azure-x86_64-with-glibc2.31)'})
2023-11-16 17:30:59,063;INFO;Connection state changed: <ConnectionState.HDR_SENT: 2> -> <ConnectionState.OPEN_PIPE: 4>
2023-11-16 17:30:59,063;DEBUG;-> BeginFrame(remote_channel=None, next_outgoing_id=0, incoming_window=65536, outgoing_window=65536, handle_max=4294967295, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:30:59,063;INFO;Session state changed: <SessionState.UNMAPPED: 0> -> <SessionState.BEGIN_SENT: 1>
2023-11-16 17:30:59,064;DEBUG;-> AttachFrame(name='6719d84a-a73c-4f8b-93b0-28cbc5a62edf', handle=2, role=True, send_settle_mode=0, rcv_settle_mode=0, source=Source(address='$cbs', durable=None, expiry_policy=None, timeout=None, dynamic=None, dynamic_node_properties=None, distribution_mode=None, filters=None, default_outcome=None, outcomes=None, capabilities=None), target=Target(address='$cbs', durable=None, expiry_policy=None, timeout=None, dynamic=None, dynamic_node_properties=None, capabilities=None), unsettled=None, incomplete_unsettled=None, initial_delivery_count=None, max_message_size=None, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:30:59,064;INFO;Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
2023-11-16 17:30:59,064;INFO;Management link receiver state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
2023-11-16 17:30:59,064;DEBUG;-> AttachFrame(name='8fcc60af-0bc1-40ef-834f-54f50be447d3', handle=1, role=False, send_settle_mode=0, rcv_settle_mode=0, source=Source(address='$cbs', durable=None, expiry_policy=None, timeout=None, dynamic=None, dynamic_node_properties=None, distribution_mode=None, filters=None, default_outcome=None, outcomes=None, capabilities=None), target=Target(address='$cbs', durable=None, expiry_policy=None, timeout=None, dynamic=None, dynamic_node_properties=None, capabilities=None), unsettled=None, incomplete_unsettled=None, initial_delivery_count=0, max_message_size=None, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:30:59,064;INFO;Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
2023-11-16 17:30:59,064;INFO;Management link sender state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
2023-11-16 17:30:59,064;DEBUG;<- Header(b'AMQP\x00\x01\x00\x00')
2023-11-16 17:30:59,065;INFO;Connection state changed: <ConnectionState.OPEN_PIPE: 4> -> <ConnectionState.OPEN_SENT: 7>
2023-11-16 17:30:59,115;DEBUG;<- OpenFrame(container_id=b'f0afceeb6e9e415193d3728ebf96f6ea_G20', hostname=None, max_frame_size=65536, channel_max=4999, idle_timeout=120000, outgoing_locales=None, incoming_locales=None, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:30:59,115;INFO;Connection state changed: <ConnectionState.OPEN_SENT: 7> -> <ConnectionState.OPENED: 9>
2023-11-16 17:30:59,166;DEBUG;<- BeginFrame(remote_channel=1, next_outgoing_id=1, incoming_window=5000, outgoing_window=65536, handle_max=255, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:30:59,166;INFO;Session state changed: <SessionState.BEGIN_SENT: 1> -> <SessionState.MAPPED: 3>
2023-11-16 17:30:59,217;DEBUG;<- AttachFrame(name=b'6719d84a-a73c-4f8b-93b0-28cbc5a62edf', handle=0, role=False, send_settle_mode=0, rcv_settle_mode=0, source=[b'$cbs', None, None, None, None, None, None, None, None, None, None], target=[b'$cbs', None, None, None, None, None, None], unsettled=None, incomplete_unsettled=None, initial_delivery_count=0, max_message_size=18446744073709551615, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:30:59,217;INFO;Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
2023-11-16 17:30:59,217;INFO;Management link receiver state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
2023-11-16 17:30:59,217;DEBUG;-> FlowFrame(next_incoming_id=1, incoming_window=65536, next_outgoing_id=0, outgoing_window=65536, handle=2, delivery_count=0, link_credit=10000, available=None, drain=None, echo=None, properties=None)
2023-11-16 17:30:59,268;DEBUG;<- AttachFrame(name=b'8fcc60af-0bc1-40ef-834f-54f50be447d3', handle=1, role=True, send_settle_mode=0, rcv_settle_mode=0, source=[b'$cbs', None, None, None, None, None, None, None, None, None, None], target=[b'$cbs', None, None, None, None, None, None], unsettled=None, incomplete_unsettled=None, initial_delivery_count=None, max_message_size=18446744073709551615, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:30:59,268;INFO;Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
2023-11-16 17:30:59,268;INFO;Management link sender state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
2023-11-16 17:30:59,268;DEBUG;CBS completed opening with status: <ManagementOpenResult.OK: 1>
2023-11-16 17:30:59,268;DEBUG;-> FlowFrame(next_incoming_id=1, incoming_window=65536, next_outgoing_id=0, outgoing_window=65536, handle=1, delivery_count=0, link_credit=10000, available=None, drain=None, echo=None, properties=None)
2023-11-16 17:30:59,319;DEBUG;-> TransferFrame(handle=1, delivery_id=0, delivery_tag=b'\x00\x00\x00\x01', message_format=0, settled=False, more=False, rcv_settle_mode=None, state=None, resume=None, aborted=None, batchable=None, payload=b'***')
2023-11-16 17:30:59,320;DEBUG;<- FlowFrame(next_incoming_id=0, incoming_window=5000, next_outgoing_id=1, outgoing_window=65536, handle=1, delivery_count=0, link_credit=100, available=0, drain=None, echo=False, properties=None)
2023-11-16 17:30:59,370;DEBUG;CBS update in progress. Token put time: 1700155859
2023-11-16 17:30:59,371;DEBUG;<- DispositionFrame(role=True, first=0, last=None, settled=True, state={'accepted': []}, batchable=None)
2023-11-16 17:30:59,421;DEBUG;CBS update in progress. Token put time: 1700155859
2023-11-16 17:30:59,422;DEBUG;<- TransferFrame(handle=0, delivery_id=0, delivery_tag=b'\x01\x00\x00\x00', message_format=0, settled=None, more=False, rcv_settle_mode=None, state=None, resume=None, aborted=None, batchable=False, payload=b'***')
2023-11-16 17:30:59,422;DEBUG;CBS Put token result (<ManagementExecuteOperationResult.OK: 0>), status code: 202, status_description: b'Accepted'.
2023-11-16 17:30:59,472;DEBUG;CBS status check: state == <CbsAuthState.OK: 0>, expired == False, refresh required == False
2023-11-16 17:30:59,473;DEBUG;-> AttachFrame(name='1d248f74-b0c7-4b94-b6f4-2c5a8b27b450', handle=3, role=False, send_settle_mode=0, rcv_settle_mode=1, source=Source(address='sender-link-1d248f74-b0c7-4b94-b6f4-2c5a8b27b450', durable=None, expiry_policy=None, timeout=None, dynamic=None, dynamic_node_properties=None, distribution_mode=None, filters=None, default_outcome=None, outcomes=None, capabilities=None), target=Target(address='amqps://commons-workers.servicebus.windows.net/t_queue', durable=None, expiry_policy=None, timeout=None, dynamic=None, dynamic_node_properties=None, capabilities=None), unsettled=None, incomplete_unsettled=None, initial_delivery_count=0, max_message_size=1048576, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:30:59,473;INFO;Link state changed: <LinkState.DETACHED: 0> -> <LinkState.ATTACH_SENT: 1>
2023-11-16 17:30:59,476;DEBUG;<- AttachFrame(name=b'1d248f74-b0c7-4b94-b6f4-2c5a8b27b450', handle=2, role=True, send_settle_mode=0, rcv_settle_mode=0, source=[b'sender-link-1d248f74-b0c7-4b94-b6f4-2c5a8b27b450', None, None, None, None, None, None, None, None, None, None], target=[b'amqps://commons-workers.servicebus.windows.net/t_queue', None, None, None, None, None, None], unsettled=None, incomplete_unsettled=None, initial_delivery_count=None, max_message_size=262144, offered_capabilities=None, desired_capabilities=None, properties=None)
2023-11-16 17:30:59,476;INFO;Link state changed: <LinkState.ATTACH_SENT: 1> -> <LinkState.ATTACHED: 3>
2023-11-16 17:30:59,476;DEBUG;-> FlowFrame(next_incoming_id=2, incoming_window=65535, next_outgoing_id=1, outgoing_window=65535, handle=3, delivery_count=0, link_credit=10000, available=None, drain=None, echo=None, properties=None)
2023-11-16 17:30:59,526;DEBUG;CBS status check: state == <CbsAuthState.OK: 0>, expired == False, refresh required == False
2023-11-16 17:30:59,527;DEBUG;CBS status check: state == <CbsAuthState.OK: 0>, expired == False, refresh required == False
2023-11-16 17:30:59,527;DEBUG;CBS status check: state == <CbsAuthState.OK: 0>, expired == False, refresh required == False
2023-11-16 17:30:59,527;DEBUG;-> TransferFrame(handle=3, delivery_id=1, delivery_tag=b'\x00\x00\x00\x01', message_format=0, settled=False, more=False, rcv_settle_mode=None, state=None, resume=None, aborted=None, batchable=None, payload=b'***')
2023-11-16 17:30:59,527;DEBUG;<- FlowFrame(next_incoming_id=1, incoming_window=5000, next_outgoing_id=2, outgoing_window=65535, handle=2, delivery_count=0, link_credit=1000, available=0, drain=None, echo=False, properties=None)
2023-11-16 17:30:59,527;DEBUG;CBS status check: state == <CbsAuthState.OK: 0>, expired == False, refresh required == False
2023-11-16 17:30:59,547;DEBUG;<- DispositionFrame(role=True, first=1, last=None, settled=True, state={'accepted': []}, batchable=None)

In [3]: sender.send_messages(single_message)
2023-11-16 17:31:28,761;DEBUG;CBS status check: state == <CbsAuthState.OK: 0>, expired == False, refresh required == False
2023-11-16 17:31:28,761;DEBUG;CBS status check: state == <CbsAuthState.OK: 0>, expired == False, refresh required == False
2023-11-16 17:31:28,762;DEBUG;-> TransferFrame(handle=3, delivery_id=2, delivery_tag=b'\x00\x00\x00\x02', message_format=0, settled=False, more=False, rcv_settle_mode=None, state=None, resume=None, aborted=None, batchable=None, payload=b'***')
2023-11-16 17:31:28,775;DEBUG;<- DispositionFrame(role=True, first=2, last=None, settled=True, state={'accepted': []}, batchable=None)

In [4]: 2023-11-16 17:31:29,095;DEBUG;Keeping 'SendClient' connection alive.

As you can see from the logs. Once the link is detached it takes close to 7 seconds to re-establish link and send message