Python和Azure Service Bus

时间:2014-08-27 10:07:49

标签: python-2.7 azureservicebus

我在设置从Python脚本到Azure Service Bus的连接时遇到问题。 C#中的类似代码(在Windows上)运行正常。

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')

这导致以下输出:

  

追踪(最近一次通话):     文件" createqueue.py",第9行,in       bus_service.create_queue('任务队列')     文件" /usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservice.py" ;,第143行,在create_queue中       request.headers = self._update_service_bus_header(request)     文件" /usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservice.py",第860行,在_update_service_bus_header中       ('授权',self._sign_service_bus_request(请求)))     文件" /usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservice.py" ;,第868行,在_sign_service_bus_request中       self._get_token(request.host,request.path)+'"'     文件" /usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservice.py",第908行,在_get_token中       resp = self._httpclient.perform_request(request)     文件" /usr/local/lib/python2.7/dist-packages/azure/http/httpclient.py" ;,第191行,在perform_request中       self.send_request_headers(connection,request.headers)     在send_request_headers文件" /usr/local/lib/python2.7/dist-packages/azure/http/httpclient.py" ;,第170行       connection.endheaders()     文件" /usr/lib/python2.7/httplib.py",第958行,在endheaders中       self._send_output(MESSAGE_BODY)     文件" /usr/lib/python2.7/httplib.py",第818行,在_send_output中       self.send(MSG)     文件" /usr/lib/python2.7/httplib.py" ;,第780行,发送       self.connect()     文件" /usr/lib/python2.7/httplib.py" ;,第1161行,在连接中       self.timeout,self.source_address)     文件" /usr/lib/python2.7/socket.py",第553行,在create_connection中       for get in getddrinfo(host,port,0,SOCK_STREAM):    socket.gaierror:[Errno -2]名称或服务未知

这里出了什么问题?

由于

2 个答案:

答案 0 :(得分:0)

AZURE_SERVICEBUS_NAMESPACE='blablabla'

您不需要为命名空间指定整个网址。

答案 1 :(得分:0)

在microsift上检查您与servicebus服务的连接。 我有同样的问题,问题是wlan0连接 - 我已经丢失了我的DHCP服务器分配的IP。 或者您的DNS无法正常工作。