tillerstarr
tillerstarr

Reputation: 2636

Unhandled Exception with Azure serviceBusService

I'm trying to send a serviceBusQueue message from an API function in my Azure mobile-service and even though it successfully creates the queueService and the queue exists I get a nasty exception. Any clue how I fix this?

I've attached the send code and stack trace.

function sendBusMessage(request, params, message, success)
{
  console.log(params);
  var queueService = azure.createServiceBusService(params.namespace,params.key);
  console.log(queueService);
  if (queueService)
  {
    queueService.sendQueueMessage('worker', message, function (error) 
    {
        if (!error) 
        {
            success();
        }
        else 
        {
            request.respond(statusCodes.INTERNAL_SERVER_ERROR,error);
        }
    });
  }
}

Exception stack:

An unhandled exception occurred. TypeError: Cannot set property 'body' of null at ServiceClient._performRequest.self._buildRequestOptions.operation (D:\home\site\wwwroot\node_modules\azure\lib\services\core\serviceclient.js:210:34) at ServiceClient._performRequest (D:\home\site\wwwroot\node_modules\azure\lib\services\core\serviceclient.js:264:7) at ServiceBusService.ServiceClient._initDefaultFilter.filter (D:\home\site\wwwroot\node_modules\azure\lib\services\core\serviceclient.js:534:7) at ServiceClient._performRequest (D:\home\site\wwwroot\node_modules\azure\lib\services\core\serviceclient.js:261:10) at ServiceBusServiceClient._buildRequestOptions (D:\home\site\wwwroot\node_modules\azure\lib\services\core\servicebusserviceclient.js:107:5) at Wrap.signRequest (D:\home\site\wwwroot\node_modules\azure\lib\services\serviceBus\wrap.js:69:5) at WrapTokenManager.getAccessToken (D:\home\site\wwwroot\node_modules\azure\lib\services\serviceBus\wraptokenmanager.js:76:5) at WrapService.wrapAccessToken.finalCallback (D:\home\site\wwwroot\node_modules\azure\lib\services\serviceBus\wrapservice.js:98:7) at ServiceClient._initDefaultFilter.filter (D:\home\site\wwwroot\node_modules\azure\lib\services\core\serviceclient.js:538:11) at WrapService.wrapAccessToken.processResponseCallback (D:\home\site\wwwroot\node_modules\azure\lib\services\serviceBus\wrapservice.js:101:5)

Upvotes: 0

Views: 308

Answers (2)

Jacek M
Jacek M

Reputation: 2418

Namespace

The namespace for configuring Node.js is the one visible under Service Bus tab (that is pretty straightforward).

Access Key

Unfortunately it can be easily confused with access keys defined for the specific messaging capability instances (such as queues). Providing an invalid access key may result in a stacktrace like the one in question.

The access key which should be used for configuring Node.js is the one accessible from the Connection Information window. To get there, you need to navigate to the Service Bus main tab (one with the cloud icon), then click Connection Information button available from the bar at the bottom. It is the Default Key right beneath the DEFAULT ISSUER section.

Configuring Namespace and Access Key

Both namespace and access key can either be passed to azure.createServiceBusService() function directly, or (when configuring a Mobile Service) set via AZURE_SERVICEBUS_NAMESPACE and AZURE_SERVICEBUS_ACCESS_KEY keys in the app settings configuration section.

Upvotes: 2

tillerstarr
tillerstarr

Reputation: 2636

Make sure you are using the top level configuration from the Service Bus->Namespace not anything deeper in the tree. An incorrect access key will not throw a useful exception (like "Can't use a queue key to access a namespace") but instead produces the problem above.

Upvotes: 0

Related Questions