Listening on the same port in foreign sessions

36 views
Skip to first unread message

M. Mahdi Mahdizadeh

unread,
Jul 12, 2025, 10:09:39 AMJul 12
to Sipwise rtpengine

Hello everyone,

In newer versions of rtpengine, before it starts listening on a port, it first checks the port against a queue of free ports (free_ports_q) to confirm its availability. This queue contains all ports that are within the configured port-min and port-max range and are not already in use by another session. If a requested port is not free, rtpengine will choose a different available port from this queue.

This can cause a problem with foreign sessions. If a port requested by a foreign session falls outside the port-min and port-max range, rtpengine will not listen on the original port. Instead, it chooses a random available port from its free ports queue. In systems that use floating IPs for High Availability (HA), this breaks the HA functionality, as it requires a re-INVITE to inform the peer of the new port being used for relaying media.

One potential solution is to use the same port-min and port-max range on all instances, but this could cause port conflicts between foreign and own sessions.

Is there another option in the rtpengine configuration to solve this problem? I would appreciate your thoughts on this.

Richard Fuchs

unread,
Jul 14, 2025, 8:11:06 AMJul 14
to rtpe...@googlegroups.com
Normally all rtpengine instances in a HA setup should have the same port range configured for the interfaces that they share. You mention that doing so might lead to a conflict between owned and foreign session, but I can't think of how that would happen? A port range on a particular interface can only be in active use by one rtpengine instance at any given time, and only that instance would be in charge of allocating ports out of it. Can you explain why you would need different port ranges?

Cheers
--
You received this message because you are subscribed to the Google Groups "Sipwise rtpengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtpengine+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/rtpengine/82f58bfd-61d7-436a-b510-f399c25982b6n%40googlegroups.com.
Message has been deleted
Message has been deleted
Message has been deleted

M. Mahdi Mahdizadeh

unread,
Jul 22, 2025, 3:52:18 PMJul 22
to Sipwise rtpengine
I have two rtpengine instances running on the same machine and listening on the same interface, each with different port ranges. Both of them are dockerized and running in user space. It's kind of an active-active setup. 

For example:
Instance A: port-min=20000, port-max=30000
Instance B: port-min=31000, port-max=40000

The problem occurs when:
Instance A creates a session using port 25000
Instance B needs to handle a foreign session from Instance A on port 25000
Since port 25000 is outside Instance B's configured range (31000-40000), it cannot listen on that port and instead allocates a new port from its own free_ports_q (31000-40000)
This breaks session continuity and requires re-INVITEs

I know this setup is unconventional but it matched our specific requirement and it had helped us with stability and maintainability over time. 

Richard Fuchs

unread,
Jul 23, 2025, 9:03:10 AMJul 23
to rtpe...@googlegroups.com
Ok I see. I'll have a quick look to see if this can be done without too much trouble, but no promises.

Cheers
Reply all
Reply to author
Forward
0 new messages