When a SIP phone goes offline during a phone conversation (e.g., an Internet line is down), the SIP server may not be aware of this fact. So if the remote party does not hang up (e.g., there is an automated IVR, or a problem with disconnect supervision) this call may stay in the “active” state for a long time. To prevent this situation, PortaSIP has a keepalive functionality.
- Customer A tries to call B, and the call is connected.
- While the call is in progress, PortaSIP periodically sends a small SIP request to the SIP phone.
- If the phone replies, this means that the phone is still online.
- If no reply (a termination response code 408, 481, or 486) is received, PortaSIP will attempt to resend the keepalive packet several times (this is done to prevent call disconnection in the case of an only temporary network connectivity problem on the SIP phone side).
- If no reply has been received following all attempts, PortaSIP will conclude that the SIP phone has unexpectedly gone offline, and will disconnect the other call leg and send an accounting record to the billing engine.
- Therefore, the call will be charged for call duration quite close to the real one.
PortaSIP can send either SIP INVITE or SIP UPDATE requests for keepalive call monitoring. For example, if the end user’s IP phone or a vendor’s VoIP gateway doesn’t support SIP INVITE for keepalive, PortaSIP can send SIP UPDATE.
This is how it works:
By default, PortaSIP sends both invite and update in the Allow header in the initial INVITE request. Thus, if the called party replies with both invite and update or only update in the Allow header, PortaSIP will send SIP UPDATE requests for keepalive call monitoring. If the called party replies with only invite, then PortaSIP will send SIP INVITE request for keepalive call monitoring.
Let’s say an administrator enables keepalive call monitoring for PBX customers who use Yealink IP phones. The keepalive interval is 300 seconds. John Doe, a PBX customer, makes a call to 12095550000. PortaSIP sends both invite and update in the Allow header in the initial INVITE request:
INVITE sip:firstname.lastname@example.org:5071 SIP/2.0 Allow: ACK, BYE, CANCEL, INFO, INVITE, UPDATE, NOTIFY, OPTIONS, REFER …
12095550000 replies with update.
SIP/2.0 200 OK Allow: ACK, BYE, CANCEL, INFO, UPDATE, NOTIFY, OPTIONS, REFER …
Thus, PortaSIP sends SIP UPDATE requests for keepalive call monitoring every 300 seconds to check whether the 12095550000 is still online.
Forbid sending SIP UPDATE requests
Sometimes, the customer’s or vendor’s equipment claims to support SIP UPDATE requests but does not handle it properly. In this case, the administrator can create a separate service policy for these devices to disable sending SIP UPDATE (e.g., exclude update from the Allow header in the initial INVITE request.) To do this, the administrator needs to enable the Forbid update method option in a service policy of voice calls service type that is assigned to a product, account, or connection.
When the service policy is assigned to a product or account, the Forbid update method option is applied to both outgoing and incoming calls. But when the service policy is assigned to a vendor connection, then the Forbid update method option is applied either to outgoing or incoming calls depending on the type of vendor connection.
Also, you can use a dynamically applied service policy to forbid sending SIP UPDATE requests depending on the customer/vendor equipment. To do this, enable the Forbid update method option in a service policy of voice calls service type and specify either a full name of a SIP phone (e.g., Linksys/SPA941-5.1.8) or a comma-separated list of patterns (e.g., Cisco%,Sipura%,Grandstream%) in the SIP end-point pattern option.
SIP termination response codes
The keepalive functionality supports three SIP termination response codes by default: 408, 481, or 486. You can add more SIP termination response codes to the list, for example, 503 and 506. To do this, open the service policy > Attributes > SIP headers > Keepalive termination codes. You can find the list of available PortaSIP error codes in PortaSIP error codes section.