Implement Configurable TCP Keepalive Settings in PJSIP Transports

This commit introduces configurable TCP keepalive settings for both TCP and TLS transports. The changes allow for finer control over TCP connection keepalives, enhancing stability and reliability in environments prone to connection timeouts or where intermediate devices may prematurely close idle connections. This has proven necessary and has already been tested in production in several specialized environments where access to the underlying transport is unreliable in ways invisible to the operating system directly, so these keepalive and timeout mechanisms are necessary.

Fixes #657
This commit is contained in:
Joshua Elson
2024-03-18 15:14:36 -04:00
parent cba82273ae
commit 555eb9d3d2
6 changed files with 184 additions and 10 deletions

View File

@@ -171,6 +171,32 @@
;type=transport
;protocol=flow
; Example IPv4 TCP transport with Keepalive options
;
;[transport-tcp]
;type=transport
;protocol=tcp
;bind=0.0.0.0
;tcp_keepalive_enable=yes ; Enable TCP keepalive (yes/no)
;tcp_keepalive_idle_time=30 ; Time in seconds the connection needs to remain idle before TCP starts sending keepalive probes
;tcp_keepalive_interval_time=10 ; The time in seconds between individual keepalive probes
;tcp_keepalive_probe_count=5 ; The maximum number of keepalive probes TCP should send before dropping the connection
; Example IPv4 TLS transport with Keepalive options
;
;[transport-tls]
;type=transport
;protocol=tls
;bind=0.0.0.0
;cert_file=/path/to/mycert.crt
;priv_key_file=/path/to/mykey.key
;cipher=ADH-AES256-SHA,ADH-AES128-SHA
;method=tlsv1
;tcp_keepalive_enable=yes ; Enable TCP keepalive (yes/no)
;tcp_keepalive_idle_time=30 ; Time in seconds the connection needs to remain idle before TCP starts sending keepalive probes
;tcp_keepalive_interval_time=10 ; The time in seconds between individual keepalive probes
;tcp_keepalive_probe_count=5 ; The maximum number of keepalive probes TCP should send before dropping the connection
;===============OUTBOUND REGISTRATION WITH OUTBOUND AUTHENTICATION============
;
; This is a simple registration that works with some SIP trunking providers.