SALES: 1-800-867-1380

IHybridConnectionStatus Interface

Provides access to the current connection state of a hybrid connection channel.

Namespace:  Microsoft.ServiceBus
Assembly:  Microsoft.ServiceBus (in Microsoft.ServiceBus.dll)

public interface IHybridConnectionStatus

The IHybridConnectionStatus type exposes the following members.

Public propertyConnectionStateGets the current connection state of the hybrid connection.

Public eventConnectionStateChangedOccurs when the connection state changes.

Windows Azure Service Bus supports only Full Trust code access security.

Hybrid connection channels are created using the NetTcpRelayBinding or any custom binding that uses the TcpRelayTransportBindingElement, where the respective ConnectionMode is set to TcpRelayConnectionMode.Direct.

Hybrid connection channels initially establish a Net.Tcp connection through the Windows Azure Service Bus Relay and will subsequently attempt to establish a direct socket connection between the application service and the connected application client. On the local subnet, the direct connection is established as a normal socket connection if the communicating parties have direct line-of-sight network visibility without intermediate firewalls. In any other case, specifically also when the communicating parties each reside behind NAT gateways and firewalls without any shared network infrastructure, the direct connection attempt is made using a NAT traversal handshake assisted by the Windows Azure Service Bus. After the direct connection is established, the channel is automatically upgraded to the direct socket connection without any information loss and is not affected by message boundaries.

IHybridConnectionStatus is a channel property that can be retrieved from the client or server channel by calling GetProperty``1(). The property is present only on channels that have been established using a binding that has been configured to use the Direct connection mode. The ConnectionState indicates whether the connection is currently in Relayed or in Direct mode. The ConnectionStateChanged events allows for registering an event handler that will be called when the connection state changes.

The following example shows how to use IHybridConnectionStatus to determine the status of a hybrid connection.


IHybridConnectionStatus hybridConnectionStatus = channel.GetProperty<IHybridConnectionStatus>();
if (hybridConnectionStatus != null)
    hybridConnectionStatus.ConnectionStateChanged += (o, e) =>
        Console.WriteLine("Connection state changed to: {0}.", e.ConnectionState);

Console.WriteLine("Enter text to echo (or [Enter] to exit):");

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft