2
votes

I am having trouble setting up a connection from a Python script to Azure Service Bus. A similar code in C# (on windows) is running fine.

from azure.servicebus import *

AZURE_SERVICEBUS_NAMESPACE='blablabla.servicebus.windows.net'
AZURE_SERVICEBUS_ISSUER='RootManageSharedAccessKey'
AZURE_SERVICEBUS_ACCESS_KEY='sdkfjlkewjrlwerjlewrjlewrjfjflsdkfjew3='

bus_service = ServiceBusService(service_namespace=AZURE_SERVICEBUS_NAMESPACE, account_key=AZURE_SERVICEBUS_ACCESS_KEY, issuer=AZURE_SERVICEBUS_ISSUER) 

bus_service.create_queue('taskqueue')

This results in the following output:

Traceback (most recent call last): File "createqueue.py", line 9, in bus_service.create_queue('taskqueue') File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservice.py", line 143, in create_queue request.headers = self._update_service_bus_header(request) File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservice.py", line 860, in _update_service_bus_header ('Authorization', self._sign_service_bus_request(request))) File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservice.py", line 868, in _sign_service_bus_request self._get_token(request.host, request.path) + '"' File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservice.py", line 908, in _get_token resp = self._httpclient.perform_request(request) File "/usr/local/lib/python2.7/dist-packages/azure/http/httpclient.py", line 191, in perform_request self.send_request_headers(connection, request.headers) File "/usr/local/lib/python2.7/dist-packages/azure/http/httpclient.py", line 170, in send_request_headers connection.endheaders() File "/usr/lib/python2.7/httplib.py", line 958, in endheaders self._send_output(message_body) File "/usr/lib/python2.7/httplib.py", line 818, in _send_output self.send(msg) File "/usr/lib/python2.7/httplib.py", line 780, in send self.connect() File "/usr/lib/python2.7/httplib.py", line 1161, in connect self.timeout, self.source_address) File "/usr/lib/python2.7/socket.py", line 553, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): socket.gaierror: [Errno -2] Name or service not known

What is going wrong here?

Thanks

2
Which version of the Python SDK are you using and when did you create your SB namespace?BrentDaCodeMonkey
Good question: do not know since I just pulled up the pip package like 2 days ago. I also tested with Python on Windows with the SDK pulled from MSDN using the WebInstaller. Same result. Oddly I have a working script creating a blob storage container. I also tested with a pre-provisioned queue and just wrote a message. This also results in the same error behavior.mvhoorn
I have the same problem, without solution yet. Not working from Windows machine nor Linux machine using python, but works with .NET.vvucetic

2 Answers

1
votes
AZURE_SERVICEBUS_NAMESPACE='blablabla'

You don't need to specify the entire URL for the namespace.

0
votes

Check your connectivity with servicebus service on microsift. I had the same problem and the issue was with wlan0 connectivity - I've lost my IP assigned by DHCP server. Or your DNS is not working as should.