Weird behavior with SIP peer

We have an Asterisk system alongside a Mitel 3300 ICP. The Asterisk system has the Mitel setup as a peer:

[3300]
type=peer
secret=xxxxxxxx
host=172.16.1.2
context=intrahealth
username=3300
qualify=yes
nat=yes

Now, calls from extensions on the Mitel system to extensions on the Asterisk system always work. Calls from Asterisk to Mitel, however, work only intermittently. A typical example:

I call extension 203 (on Mitel) from extension 334 (on Asterisk). The first time, I’ll get a busy signal and Asterisk will report “CONGESTION”. A tcpdump shows this that the Mitel is returing a 404 not found error to Asterisk.

Now, if I then wait for a minute or so and retry, the same call with go through and repeated retries will work for a period of around 10 minutes (though this seems to vary).

I can also get the connection working by first dialing an Asterisk extension from Mitel and then dialing Asterisk to Mitel. Call will then work until about 10 minutes of inactivity between the systems.

It seems here that some Asterisk -> Mitel (or vice versa) keep alive is failing and that, after a period of inactivity, the Asterisk and Mitel systems need to renegotiate. Does anyone have any insight into this?

you may be having a problem with the firewall / nat …

Our setup is a bit strange. There is a firewall between the Asterisk and Mitel systems. Mitel is sitting on a 172 network and Asterisk is on a 192 network with a firewall in between. Now, those networks are routed so the two systems can and do communicate, but I do have this strange issue. What ports would Mitel and Asterisk communicate on? Just UDP 5060?

Outbound, the RTP range specified by the Mitel. Inbound, the RTP range specified by Asterisk. This assumes no translation at the gateway.

It appears that this was a firewall issue. The firewall wasn’t blocking communications, but our netscreen was doing some SIP “optimization”. After disabling that feature the systems communicate without issue.