Connectivity issues to the Service Bus from Python


  • I have some python scripts which use Topics and Subscriptions on the Azure Service Bus  (, I'm using a standard Azure Library and I can replicate my networking issue with a very simple script.

    If I execute this script it will work find after a period of time,  but after an initial connection to a number of wifi networks, it simply fails to run,  and I get 401 Authorization errors.    

    It's  definitely not an Authorization issue, my shared access policy has not changed,  and if I leave it alone for a period of time, it will work perfectly afterwards.

    So my question is, how can I turn on debugging for this very simple script , to see more information at a DEBUG level on whats happening during the connection ?

    I can ping the endpoint, but thats not reallt the same as connecting.

    Any help , or pointers towards python documentation would be great.



    from azure.servicebus import ServiceBusService, Message, Topic, Rule, DEFAULT_RULE_NAME

    bus_service = ServiceBusService(

    msg = Message(b'Test Message')
    bus_service.send_queue_message('taskqueue', msg)

    Friday, February 24, 2017 9:12 PM

All replies

  • I'd also like to see a way to speed up the throughput, as performace isn't great.

    Do you have a callback method so I can process message asynchronously ? or even an example with multithreaded handling ?

    It looks like this library does a logon for every bus_service.send_topic_message(topic_name, msg) , so the performance suffers.  Can I open a connection, send messages and then close it ?

    Friday, February 24, 2017 9:30 PM
  • ok same issue again,  I have the simplest script in the world, and it simply fails to send a message ?!?

    How can I trck down this issue ?  my credentials haven't changed, and they will work perfectly in 1 hour.

    If I can't get this working today I'm going with RabbitMQ.

    azure.common.AzureHttpError: Unauthorized
    <Error><Code>401</Code><Detail>ExpiredToken: . TrackingId:6de1fff1-6206-463f-bc46-4c53e8666ea0_G5,, Timestamp:2/27/2017 9:22:40 AM</Detail></Error>

    Monday, February 27, 2017 9:24 AM
  • Hi Martin - I have created an issue in the proper GitHub repo for Azure Python.

    Tuesday, February 28, 2017 11:01 PM
  • I'm using the same simple script, and got the same error with the azure.common.AzureHttpError: Unauthorized 401. Did you find a solution?

    Thanks, GF

    Tuesday, March 21, 2017 9:02 PM