I am trying to connect to a local instance of Windows service bus using Node.js.
I have obtained my connection string from powershell:
PS C:\Users\Juan> Get-SBClientConfiguration
Endpoint=sb://juan-vaio/MyNamespace;StsEndpoint=https://juan-vaio:9355/MyNamespace;RuntimePort=9354;ManagementPort=9355
However when using this connection string from Node using the azure-node package I get the following error:
CODE
var connectionString = "Endpoint=sb://localhost/MyNamespace;StsEndpoint=https://localhost:9355/MyNamespace;RuntimePort=9354;ManagementPort=9355";
var serviceBusService = Azure.createServiceBusService(connectionString);
ERROR
throw new Error('Invalid connection string setting key "' + key + '"');
^
Error: Invalid connection string setting key "runtimeport"
I have tried removing the runtimeport setting of the connection string, but then it fails because of the ManagementPort. And if I remove that one two it finally cannot connect because of incomplete settings:
throw new NoMatchError('The provided connection string "' + connectionString
^
NoMatchError: The provided connection string "Endpoint=sb://localhost/MyNamespace;StsEndpoint=https://localhost:9355/MyNamespace;"
does not have complete configuration settings.
Googling a little bit I have found that it seems like a known issue:
https://github.com/Azure/azure-sdk-for-node/issues/1254
But I am wondering if there is a workaround for this or if maybe I am doing something wrong.
The Azure SDK for Node is made for Microsoft Azure Service Bus, not for Service Bus on Windows Server. So you can not directly use it to connect local Service Bus.
Their connection string are differect, see below:
For Azure Service Bus, the formule like this:
Endpoint=sb://<azure-sb-name>.servicebus.windows.net/;SharedAccessKeyName=<key-name>;SharedAccessKey=<key>
For Service Bus on Windows Server, the formule like this: Endpoint=sb://yourHost/ServiceBusDefaultNamespace;StsEndpoint=https://yourHost:9355/ServiceBusDefaultNamespace;RuntimePort=9354;ManagementPort=9355
According to the offical doc https://msdn.microsoft.com/en-us/library/dn441376.aspx, Service Bus for Windows Server offers REST API similar to the API offered by Microsoft Azure Service Bus.
So you can refer to the Azure Service Bus REST APIs https://msdn.microsoft.com/en-us/library/hh780717.aspx and replace the arguments for Azure with the local's.
However, I suggest you to use the Service Bus for Windows Server SDK in dotNet(https://msdn.microsoft.com/en-us/library/dn441398.aspx and https://msdn.microsoft.com/en-us/library/dn441414.aspx), or refer to the doc https://msdn.microsoft.com/en-us/library/dn574799.aspx to try to connect from Java with AMQP.