Raise the open-file limit
Every app with an open connection takes one open file, and Linux limits how many a process can have. When the limit is reached, new apps can’t connect. pgw tells you at startup when the limit is lower than the number of connections that it is set to accept (app_max_connections):
1
Set the limit in the unit
Set the limit in the
[Service] section of the systemd unit. The unit in Run pgw under systemd already has this line.2
Restart pgw
3
Check the limit
Raise the UDP receive buffer
From a PBX that uses UDP, pgw receives every call and every registration answer on one socket. A burst, such as when the PBX restarts and many devices register again, can overflow that socket’s buffer, and the kernel silently drops what doesn’t fit. The symptom is calls and registrations that time out during busy moments. A PBX that uses TCP doesn’t have this problem, so you can set the upstream’stransport to tcp instead of doing these steps.
1
Check for drops
2
Raise the buffer
Set the default and the maximum receive buffer. Start with 4 MiB.
3
Restart pgw
pgw’s socket gets the new default when pgw starts.
Keep the path to the PBX open
Firewalls and NAT devices forget a connection that stays silent. Typical limits are 30 seconds for UDP through a NAT, and several minutes for TCP through a cloud firewall. If a firewall or NAT device forgets the path between pgw and the PBX, the PBX’s next call doesn’t arrive, and nothing in either log says why. pgw prevents this by itself. It sends each upstream an OPTIONS request everykeepalive_seconds, 30 by default, which keeps the path open. The answer also feeds the metric pgw_upstream_up, so you see when the PBX stops responding. Follow these rules for keepalive_seconds:
- Keep the keepalive on when a NAT, a firewall, or a cloud network sits between pgw and the PBX.
- Set
keepalive_secondsbelow the shortest idle limit on the path. - Set it to
0only when pgw and the PBX share a network without such devices, or when you don’t want the PBX to log every OPTIONS.
Next steps
Metrics
Watch open connections and
pgw_upstream_up to confirm that the limits hold.Troubleshooting
Find the cause when new app connections fail or the PBX stops answering.