ReliableSession.InactivityTimeout Property

Definition

Gets or sets an interval of time that a service can remain inactive before closing.

public:
 property TimeSpan InactivityTimeout { TimeSpan get(); void set(TimeSpan value); };
public TimeSpan InactivityTimeout { get; set; }
member this.InactivityTimeout : TimeSpan with get, set
Public Property InactivityTimeout As TimeSpan

Property Value

The TimeSpan that specifies the interval of time that a service remains inactive before closing. The default value is 10 minutes.

Exceptions

The value set is less than or equal to zero.

Examples

// Create a new reliable session object
ReliableSessionBindingElement bindingElement = new ReliableSessionBindingElement();
ReliableSession reliableSession = new ReliableSession(bindingElement);

// Now you can access property values
Console.WriteLine("Ordered: {0}", reliableSession.Ordered);
Console.WriteLine("InactivityTimeout: {0}", reliableSession.InactivityTimeout);
' Create a new reliable session object
Dim bindingElement As ReliableSessionBindingElement = New ReliableSessionBindingElement()
Dim reliableSession As ReliableSession = New ReliableSession(bindingElement)

' Now you can access property values
Console.WriteLine("Ordered: {0}", reliableSession.Ordered)
Console.WriteLine("InactivityTimeout: {0}", reliableSession.InactivityTimeout)

Remarks

The property gets and sets the value of the InactivityTimeout property.

Activity on a channel is defined as receiving an application or infrastructure message. The inactivity timeout property controls the maximum amount of time to keep an inactive session alive. If more than the InactivityTimeout specified time interval passes with no activity, the session is aborted by the infrastructure and the channel faults. The reliable session is torn down unilaterally.

If the sending application has no messages to send then the reliable session is normally not faulted because of inactivity; instead a keep-alive mechanism keeps the session active indefinitely. Note that the dispatcher could independently abort the reliable session if no application messages are sent or received. Thus, the inactivity timeout typically expires if network conditions are such that no messages of any sort are received or if there is a failure on the sender.

Setting this timeout prevents the server from holding onto a security session if the client does not close it. If the security session has not received a message for the inactivity interval of time, it is closed by the server. This mitigates a potential denial of service attack.

When using a reliable session, there are two different inactivity timers that must be satisfied to keep the connection alive. If either of these inactivity timers goes off, then the connection is dropped.

  • The first inactivity timer is on the reliable session and is called the InactivityTimeout. This inactivity timer fires if no messages, either application or infrastructure, are received within the timeout period. An infrastructure message is a message that is generated for the purpose of one of the protocols in the channel stack, such as a keep alive or an acknowledgment, rather than containing application data.

  • The second inactivity timer is on the service and uses the ReceiveTimeout setting of the binding. This inactivity timer fires if no application messages are received within the timeout period.

Since the connection is dropped if either inactivity timer fires, increasing InactivityTimeout once it is greater than ReceiveTimeout has no effect. The default for both of these timeouts is 10 minutes, so you always have to increase both of them to make a difference when using a reliable session.

Applies to