Make HTTP idle (keepalive) timeout configurable

14 views
Skip to first unread message

H Yavari

unread,
Feb 26, 2026, 2:04:38 PMFeb 26
to Sipwise rtpengine
Hi all,

The HTTP/HTTPS listener (listen-http / listen-https) currently uses a fixed 5-second idle timeout; I’d like to suggest adding a config option for it.

Issue:

The HTTP idle (keepalive) timeout for the HTTP/WS listener is not configurable. In practice it is fixed at 5 seconds (the libwebsockets default when keepalive_timeout is not set). That can be problematic when:
- A load balancer (e.g. AWS ALB) or client expects a longer idle timeout and closes connections before the next request.
- We want to align or tune the timeout for health checks or control traffic (e.g. NG over HTTP).

Root cause:
RTPEngine uses libwebsockets for HTTP/WS. The idle timeout is controlled by the vhost option keepalive_timeout in lws_context_creation_info when creating the vhost. In daemon/websocket.c, the context and vhost are created without setting this field, so libwebsockets uses its default (0 → 5 s for HTTP/1.1). 
See e.g. libwebsockets’ include/libwebsockets/lws-context-vhost.h: “(default = 0 = 5s, 31s for http/2)”.

Proposed solution:
Add a config/CLI option (e.g. --http-idle-timeout or --http-keepalive-timeout, in seconds) and pass it into keepalive_timeout when creating the HTTP and HTTPS vhosts in websocket_init(). Keep the default at 0 so that existing deployments keep the current behaviour (LWS default 5 s). 

I’d be happy to prepare a patch (including config-file and docs updates) if this direction works for the project.

Best regards,
Hossein

Richard Fuchs

unread,
Feb 26, 2026, 7:00:05 PMFeb 26
to rtpe...@googlegroups.com
On 26/02/2026 15.04, H Yavari wrote:
> I’d be happy to prepare a patch (including config-file and docs
> updates) if this direction works for the project.

Sure, sounds like a useful addition. Thanks!

Cheers

H Yavari

unread,
Feb 27, 2026, 11:51:31 AMFeb 27
to Sipwise rtpengine
Hi Richard,

It's ready and tested locally. Please review and merge whenever you can.


Thank you.

Regards,
Hossein

Reply all
Reply to author
Forward
0 new messages