question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[ServiceBus] Send message didn't recovered after network disconnect.

See original GitHub issue
  • Package Name: azure-servicebus
  • Package Version: 7.0.0b8
  • Operating System: Mac 10.15.5
  • Python Version: 3.6.10

Describe the bug sending message was infinitely blocked when network interrupted

To Reproduce Steps to reproduce the behavior: with the function from example like this

def send_batch_message(sender):
    batch_message = sender.create_message_batch()
    print('disconnect network here')
    time.sleep(15)
    for _ in range(10):
        try:
            batch_message.add_message(ServiceBusMessage("Session Message inside a ServiceBusMessageBatch", session_id=SESSION_ID))
        except ValueError:
            # ServiceBusMessageBatch object reaches max_size.
            # New ServiceBusMessageBatch object can be created here to send more data.
            break
    sender.send_messages(batch_message)
    print('success')
  1. disconnect the network in time.sleep()
  2. then wait till it to sender.send_messages
  3. reconnect network
  4. infinite block

Expected behavior should have mechanism to retry or raise exception at least

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cropsecommented, Nov 26, 2020

I’m using Mac as test operating system, so probably is the specific issue only on macOS.

here is entire code:

#!/usr/bin/env python

import time
from azure.servicebus import ServiceBusClient, ServiceBusMessage

CONNECTION_STR = ""
TOPIC_NAME = ''
SUBSCRIPTION_NAME = ''
SESSION_ID = ''


def send_batch_message(sender):
    batch_message = sender.create_message_batch()
    print('disconnect network here')
    time.sleep(15)
    for _ in range(10):
        try:
            batch_message.add_message(ServiceBusMessage("Session Message inside a ServiceBusMessageBatch", session_id=SESSION_ID))
        except ValueError:
            # ServiceBusMessageBatch object reaches max_size.
            # New ServiceBusMessageBatch object can be created here to send more data.
            break
    print('start to send message, reconnect your network!!')
    sender.send_messages(batch_message)
    print('success !!')


servicebus_client = ServiceBusClient.from_connection_string(conn_str=CONNECTION_STR, logging_enable=False, retry_total=10)
with servicebus_client:
    receiver = servicebus_client.get_subscription_receiver(
        topic_name=TOPIC_NAME,
        subscription_name=SUBSCRIPTION_NAME
    )
    sender = servicebus_client.get_topic_sender(TOPIC_NAME)
    with sender:
        send_batch_message(sender)

print("Receive is done.")
0reactions
yunhaolingcommented, Jan 6, 2021

hey @cropse, we have enhanced the underlying C library to be able to detect error IO status on MacOS.

uamqp v1.2.13 is released today to include the fix. Please upgrade to the latest uamqp version (e.g. pip install uamqp --upgrade) to see if it solves your problem.

I’m closing the issue now, feel free to reopen if you still get trouble with the latest version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Insulate Azure Service Bus applications against outages and ...
After the problem has been fixed, Service Bus becomes available again. Typically, an outage doesn't cause loss of messages or other data.
Read more >
Azure Service Bus QueueClient not reconnecting after ...
When I get a network disconnection the QueueClient will not reconnect back to Azure Service Bus when the network connection is restored.
Read more >
Azure Service Bus and its Complete Overview | Serverless360
Furthermore, the producer does not have to wait for a reply from the consumer in order to continue to process and send messages....
Read more >
Advanced Features with Azure Service Bus - YouTube
Azure Service Bus Messaginghttps://docs.microsoft.com/azure/ service-bus - messaging / service-bus - messaging -overview?
Read more >
Receiving messages from Azure Service Bus in C# - Ciaran O ...
ServiceBus library. Connecting to Service BusPermalink. Same as last time, we need to get our Connection String from the Azure Portal. Then we ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found