Table of Contents

Keeping connection active (InactivityTimeout and EnquireLink)

InactivityTimeout

To save server resources, it is useful to disconnect inactive clients. In general, inactive client is the one who neither sends neither receives commands (messages).

There is a parameter InactivityTimeout with default value of 2 minutes for SmppServerClient instances. The SmppServer closes connection to clients based on this timer. It is possible to disable InactivityTimeout by assigning it value TimeSpan.Zero.

Example of setting InactivityTimeout for 15 seconds once an SMPP-client is connected:

SmppServer _server = new SmppServer(new IPEndPoint(IPAddress.Any, 7777));

_server.evClientConnected += (s, client) => {
    client.InactivityTimeout = TimeSpan.FromSeconds(15);
};

_server.Start();

InactivityTimeout is possible to set inside event-handler for evClientConnected event only.

When there is no messages to send/receive but the connection has to be kept the EnquireLink command is engaged.

It is possible to perform an automatic connection check for SmppServerClient or SmppClient using property EnquireLinkInterval. The EnquireLinkInterval is the inactivity time interval after which the command EnquireLink is sent automatically.

EnquireLink example:

SmppServer _server = new SmppServer(new IPEndPoint(IPAddress.Any, 7777));
_server.Start();
_server.evClientBind += (s, client, bind) => {
    client.EnquireLinkInterval = TimeSpan.FromSeconds(15);
};

In that example, we configure the SmppServerClient instance to check connection each 15 seconds of SMPP-client inactivity. It is possible to set EnquireLinkInterval in event-handlers for evClientConnected event or evClientBind event.

An automatic connection check is started only after successful Bind. Client without Bind considered inactive and will be disconnected if InactivityTimeout was set.

Please note, values InactivityTimeout and EnquireLinkInterval are to be set for each instance of SmppServerClient created i.e. for each client connected.

The event handler for event evClientDisconnected is called when client disconnects.