What is wrong here - incoming calls dropping after 15 minutes

FreePBX version 13
Incoming PSTN trunks going to a Cisco 1760 running IOS 12.4.25d
This is configured to go to Chan SIP
All extensions are using pjsip
Problem happens regardless of maker and model of extension
Both PSTN gateway and FreePBX are on the same LAN with no firewall in between

Outgoing calls are fine. All incoming calls drop after 15 minutes with an error in the log about retransmission timeout.

Adding the command “session-timers=refuse” into Chan SIP configuration fixes the problem.

My question is this - it SEEMS to me that the session-timers=refuse command is a hack and I’m covering up brokenness in the trunk definition either in FreePBX or in the Cisco IOS configuration. Or, it’s a bug in the IOS firmware…

Has anyone else run into this?

By default the session timer is set to 1800 (that’s in seconds) and at the half way point (i.e. 15 minutes) a reINVITE is sent to re-establish the session. I suspect the reINVITE is failing and that ends up breaking the call. Your config in effect ignores the timers and thus eliminates the symptom, but the underlying problem remains. As to why the reINVITE fails, could be NAT misconfig, a router SIP ALG interfering, possibly something else. You will have to look at the sip debug** to try to figure out what’s going on.

** or if on 14 use sngrep

1 Like

“Both PSTN gateway and FreePBX are on the same LAN with no firewall in between”

no NAT or alg issue there.

To get it to work I had to manually define the SIP params for trunk as follows:


Should that perhaps be


Reinvite is not a valid value for parameter insecure, in fact it has nothing to do with.

can you trace a call with wireshark? That will save a whole lot of guessing and tell you the failure point. Make sure to disable your “fix” so you capture the drop.

Yes, although I have a question on that - when running tcpdump on the FreePBX system I tried the following:

tcpdump -s0 -w/tmp/capture.pcap -C50 udp and host

and I get an enormous capture file, but when I tried limiting it:

tcpdump -s0 -w/tmp/capture.pcap -C50 udp and host and port 5160

I get nothing. (chan_sip is set to listen to 5160, pjsip to 5060)

Any suggestions on filtering to just get the SIP events or am I going to have to digest the entire thing and just pick out the bits?

Another possible “less of a hack” way of “fixing” this is to adjust the Cisco, putting this in the config:

voice service voip
fax protocol pass-through g711alaw
modem passthrough nse codec g711alaw
min-se 14400

increases the time that the re-INVITE is sent out. (4 hours in this case) It’s still a hack since FreePBX is still not handling the re-INVITES properly (or the re-INVITES are incorrect) but it does have the benefit of allowing FreePBX to clear stale calls (if you are OK with a max call length)

From the looks of it, SIP Session timer support was added into Cisco IOS in the Technology versions 12.2/12.3 and wasn’t in the mainline until IOS version 12.4. Most of the configs and discussion out there about using a Cisco router as a VoIP gateway for Asterisk appear to predate this so it may simply be that when chan_sip was being developed and tested, if it was tested against a Cisco device that device didn’t have session timer support at all.

It SEEMS to me that most running Asterisk gateways pick up one of those ultra-cheap Linksys gateways (which have flooded Ebay for years, and many of which are not even real they are counterfeits) and aren’t using “enterprise” gear like a Cisco so I would not at all be surprised if a tcpdump shows errors in the re-INVITES from a Cisco device.

I have had no luck at all connecting the Cisco to pjsip so clearly there’s been little interest among the Asterisk developers in even testing with this gear let alone supporting it. PSTN gateways aren’t really very popular in the Asterisk crowd anyway as so many of them are trying to wring the last few dollars of savings out of the system.

The other problem with it is that Cisco only added authentication support for SIP username/password into IOS very late in development, IOS 15 seems to be the first version that really properly supports it, prior to that authentication is only via IP address. pjsip seems to be geared towards authentication.

This also allows me to knock down the sip session timer to a couple of minutes to make getting a packet capture more manageable.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.