Table of Contents
List of Examples
Table of Contents
This modules allows kamailio to control the TCP options (such as the keepalive mechanism), on demand, and on a per-socket basis.
Note: the keepalive functions only work on systems with the HAVE_TCP_KEEPIDLE, HAVE_TCP_KEEPCNT and HAVE_TCP_KEEPINTVL macros defined (currently only Linux).
Enables keepalive on a TCP connection.
Meaning of the parameters is as follows:
conid (optionnal): the kamailio internal connection id on which TCP keepalive will be enabled. If no parameter is given, the keepalive mechanism will be enabled on the current message source connection.
idle (seconds): the time before the first keepalive packet is sent out.
count: number of non-acked keepalive before reseting the connection.
interval (seconds): time between two keepalive probes.
Retuns 1 on success, -1 on failure.
Example 1.1. tcp_keepalive_enable
usage
request_route { if (is_method("INVITE")) { $avp(caller_conid) = $conid; t_on_reply("foo"); } ... } onreply_route[foo] { if (is_method("INVITE") && status == 200) { # enable on callee's connection tcp_keepalive_enable("60", "5", "5"); # enable on caller's connection tcp_keepalive_enable("$avp(caller_conid)", "60", "5", "2"); } ... }
Disables keepalive on a TCP connection.
Meaning of the parameters is as follows:
conid (optionnal): the kamailio internal connection id on which TCP keepalive will be disabled. If no parameter is given, the keepalive mechanism will be disabled on the current message source connection.
Retuns 1 on success, -1 on failure.
Example 1.2. tcp_keepalive_disable
usage
request_route { ... if (is_method("BYE")) { $avp(bye_conid) = $conid; t_on_reply("foo"); } ... } onreply_route[foo] { ... if (is_method("BYE") && status == 200) { tcp_keepalive_disable(); tcp_keepalive_disable("$avp(bye_conid)"); } ... }
Sets the connection lifetime of a connection (TCP).
Meaning of the parameters is as follows:
conid (optionnal): the kamailio internal connection id on which to set the new lifetime. If no parameter is given, it will be set on the current message source connection.
lifetime (seconds): the new connection lifetime.
Retuns 1 on success, -1 on failure.
Example 1.3. tcp_set_connection_lifetime
usage
... # use 10s as default lifetime tcp_connection_lifetime=10 ... request_route { ... if (is_method("REGISTER") && pv_www_authenticate("$td", "xxx", "0")) { # raise the TCP lifetime to a bigger value tcp_set_connection_lifetime("3605"); } ... }