How to: Modify the Service Bus Connectivity Settings
Updated: June 17, 2014
The Microsoft.ServiceBus.ConnectivitySettings class contains settings that affect all endpoints, based on the Microsoft.ServiceBus.NetOnewayRelayBinding or Microsoft.ServiceBus.NetEventRelayBinding bindings, that are active in the current application domain. The reason for the shared nature of these settings is that the connectivity path to Service Bus is identical across all endpoints in the same process. Most corporate network environments prefer to limit ports opened to outbound traffic, and typically restrict outbound HTTP and TCP traffic to the same narrow range of ports.
By default, all service endpoints listening for messages using one of these two bindings connect to Service Bus using outbound TCP port 9351 or 9552.
If neither of these ports is available for outbound communication, you can set the SystemConnectivity property of the connectivity settings to Http, which enables the HTTP polling through outbound ports 80 and 443 using RFC 2616-compliant HTTP requests. RFC 2616 strongly recommends constraining the concurrent requests to a particular domain be limited to two, and the operating system and networking devices or upstream proxies can enforce that limit. Considering that, the HTTP polling mode is using a single HTTP connection to implement polling. All messages destined for all one-way and event endpoints in the current application domain are multiplexed through the HTTP polling connection and distributed locally.
To set or modify Service Bus connectivity settings
You can set or modify the connectivity settings with the SystemConnectivity property. For example:
The following example, taken from the Echo Service Bus sample, shows how to set the connectivity mode in a command-line application.
ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http; Console.Write("Your Service Namespace (ex. sb://<ServiceNamespace>.servicebus.windows.net/): "); string serviceNamespace = Console.ReadLine(); Console.Write("Your Issuer Name: "); string issuerName = Console.ReadLine(); Console.Write("Your Issuer Secret: "); string issuerSecret = Console.ReadLine(); // Create the service URI based on the service namespace name. Uri address = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, "EchoService");