<<

options

As per Net::Server documentation, override "options" to provide your own custom options to the Net::Server* object. This allows us to use the Net::Server infrastructure for configuration rather than hacking our own configuration into the object.

post_configure_hook

As per Net::Server documentation, this method validates our custom configuration.

post_accept_hook

This hook occurs after the client connection socket is created, which gives us an opportunity to enable support for TCP keepalives using the SO_KEEPALIVE socket option.

By default, the kernel-level defaults (in seconds) are used. You can view these in the output of "sysctl -a": net.ipv4.tcp_keepalive_intvl = 75 net.ipv4.tcp_keepalive_time = 7200

Alternatively, you can use "custom_tcp_keepalive_time" and "custom_tcp_keepalive_intvl" to define your own custom values for the socket. Note that these parameters are defined at the top server-level and not on the listener-level.

If you lower "custom_tcp_keepalive_time" below 75, you will also need to set "custom_tcp_keepalive_intvl". The "tcp_keepalive_time" is the initial time used for the keepalive timer, and the "tcp_keepalive_intvl" is the time used for subsequent keepalive timers. However, timers only send keepalive ACKs if the idle time elapsed is greater than "tcp_keepalive_time".

Thus, if "tcp_keepalive_time = 10" and "tcp_keepalive_intvl = 5", a keepalive ACK will be sent every 10 seconds of idle time. If "tcp_keepalive_intvl = 10" and "tcp_keepalive_time = 5", a keepalive ACK will be sent after 5 seconds of idle time, and the next keepalive ACK will be sent after 10 seconds of idle time. Generally speaking, it's best to set "tcp_keepalive_time" to be higher than "tcp_keepalive_intvl".

Reminder: once these settings are set on the socket, they are handled by the operating system kernel, and not by the SIP server application. If you are having trouble with your settings, monitor your TCP traffic using a tool such as "tcpdump" to review and refine how they work.

<<