How Can I Manually Send A BYE Message To A PSTN Gateway?
Bad things happen sometimes during development. It's just a fact of life. During my experience I've left billing records open on PSTNii gateway providers, which means they would get a bit upset with me since they could not bill certain calls.
The reason some calls were left open is that BYE messages were not properly record-routed, so the PSTN gateway was never informed that the call ended.
I came up with a technique to manually close billing records by using sipsak to send a BYE message.
This assumes that your have MySQL accounting turned on and have captured the INVITE and BYE message in the MySQL acc table.
In order to manually close a billing record you must first find the INVITE message in the MySQL acc table. When you locate the INVITE message you only need to grab the sip_callid field.
Next create a file on disk with your favorite editor. The contents of the file will be the BYE message and should look like the example below.
NOTE: Make sure you place the sip_callid from the MySQL acc table in to the Call-Seq header in this file.
BYE sip:firstname.lastname@example.org SIPi/2.0
NOTE: Make sure there is an extra blank line following the Content-Length header.
Once you have your BYE message constructed you can use sipsak to send it to the PSTN gateway.
sipsak -f bye.txt -s PSTN-GW-IP-ADDRESS
When you run the command you can ^C to stop it since sipsak will likely re-transmit BYE messages.