I am not able to send message to service bus.
The error is:
[CPF-API] 2025-04-15:17:53:36,801 INFO [_transport.py:connect:207] Transport connection failed: TimeoutError('timed out')
[CPF-API] 2025-04-15:17:53:36,801 INFO [_pyamqp_transport.py:_handle_amqp_exception_with_condition:940] AMQP error occurred: (AMQPConnectionError('Error condition: ErrorCondition.SocketError\n Error Description: Failed to initiate the connection due to exception: timed out')), condition: (<ErrorCondition.SocketError: b'amqp:socket-error'>), description: ('Failed to initiate the connection due to exception: timed out').
[CPF-API] 2025-04-15:17:53:38,402 INFO [_base_handler.py:_backoff:438] 'servicebus.pysdk-91a7ece8' has an exception (ServiceBusConnectionError('Failed to initiate the connection due to exception: timed out Error condition: amqp:socket-error.')). Retrying...
[CPF-API] 2025-04-15:17:53:39,406 INFO [_transport.py:connect:207] Transport connection failed: TimeoutError('timed out')
[CPF-API] 2025-04-15:17:53:39,406 INFO [_pyamqp_transport.py:_handle_amqp_exception_with_condition:940] AMQP error occurred: (AMQPConnectionError('Error condition: ErrorCondition.SocketError\n Error Description: Failed to initiate the connection due to exception: timed out')), condition: (<ErrorCondition.SocketError: b'amqp:socket-error'>), description: ('Failed to initiate the connection due to exception: timed out').
[CPF-API] 2025-04-15:17:53:42,607 INFO [_base_handler.py:_backoff:438] 'servicebus.pysdk-91a7ece8' has an exception (ServiceBusConnectionError('Failed to initiate the connection due to exception: timed out Error condition: amqp:socket-error.')). Retrying...
[CPF-API] 2025-04-15:17:53:43,616 INFO [_transport.py:connect:207] Transport connection failed: TimeoutError('timed out')
[CPF-API] 2025-04-15:17:53:43,616 INFO [_pyamqp_transport.py:_handle_amqp_exception_with_condition:940] AMQP error occurred: (AMQPConnectionError('Error condition: ErrorCondition.SocketError\n Error Description: Failed to initiate the connection due to exception: timed out')), condition: (<ErrorCondition.SocketError: b'amqp:socket-error'>), description: ('Failed to initiate the connection due to exception: timed out').
[CPF-API] 2025-04-15:17:53:50,17 INFO [_base_handler.py:_backoff:438] 'servicebus.pysdk-91a7ece8' has an exception (ServiceBusConnectionError('Failed to initiate the connection due to exception: timed out Error condition: amqp:socket-error.')). Retrying...
[CPF-API] 2025-04-15:17:53:51,174 INFO [_transport.py:connect:207] Transport connection failed: TimeoutError('timed out')
[CPF-API] 2025-04-15:17:53:51,174 INFO [_pyamqp_transport.py:_handle_amqp_exception_with_condition:940] AMQP error occurred: (AMQPConnectionError('Error condition: ErrorCondition.SocketError\n Error Description: Failed to initiate the connection due to exception: timed out')), condition: (<ErrorCondition.SocketError: b'amqp:socket-error'>), description: ('Failed to initiate the connection due to exception: timed out').
[CPF-API] 2025-04-15:17:53:51,174 INFO [_base_handler.py:_do_retryable_operation:398] 'servicebus.pysdk-91a7ece8' operation has exhausted retry. Last exception: ServiceBusConnectionError('Failed to initiate the connection due to exception: timed out Error condition: amqp:socket-error.').
My code is:
def send_message_to_service_bus(result): # function to send message to service bus
service_bus_client = ServiceBusClient.from_connection_string(STR)
try:
with service_bus_client:
sender = service_bus_client.get_queue_sender(queue_name=QUEUE)
message = ServiceBusMessage(result)
sender.send_messages(message)
logger.info(f"Query sent to Azure Service Bus")
except Exception as e:
logger.error(f"Failed to send message to Service Bus: {e}")
Where Am I wrong??