Pjsip issues: wrong phone rings

Not sure how to better title this, but what i see happening is that after the internet drops and comes back sometimes the PBX is confusing phones. One time x101 rang but the server thought it was x108 that took the call. On another PBX x1005 rang but it thinks it’s x1002 that was on the phone. In both cases the phones are at the same public IP, so I assume that’s related to the issue. I’m sure there is some setting that was changed somewhere. What am I missing?

Also, in both cases restarting the phone seems to fix the issue. The PBX sees the correct phone unregister and re-register and then the behavior is corrected. Extensions have randomly generated and unique SIP secrets.

There’s no setting in PJSIP. It sends the SIP INVITE to the registered IP address and port. If the router changes the mapping such that the external IP address and port go to a different internal IP address and port, then this would happen. You could check by looking at the log of where they originally registered and where Asterisk sent the SIP INVITE. If it’s the same, then that’s the problem and outside of anything Asterisk can do.

That’s probably it. The first phone to reach out registers on 5160 and the others get another port number. I’m guessing that restarting the router or breaking the connection is causing the ports to get moved around. Whats the best way around this if I dont have access to the router?

If the phones are scattered over the internet, I can only think of setting a very short re-registration interval. and setting new registration to overwrite old ones.

If they are all on one remote, site, use a VPN.

Between each phone and the phone system, or between the router and the phone system?

Depending on your environment but if the phones are all over and not in a single location then between the individual phones and the phone system.

Between the single remote site and the site with Asterisk.

I think there is a risk that the VPN “connection” will get shuffled.

Yea, you are correct. I guess it all depends on the upstream hardware and how it handles the different connections. I guess if it’s screwing up the SIP sessions then maybe it won’t be that good at handling NAT of the OpenVPN tunnels either.

There is almost certainly no need to set up a VPN or other complex solution.

First, check the value of Contact at Reports → Asterisk Info → Peers to see whether one of the phones at a multiphone location shows the same port as its SIP local port. If so, that indicates that the router/firewall at that location rewrites the source port only to avoid a conflict. In that case, setting a unique local port on each device should eliminate this issue.

However, regardless of the above, set a short registration expiry, e.g. 120 seconds on each device. If source ports are always being rewritten, this will at least ensure that any calls received at least two minutes after an internet outage is over will be properly routed. If you can avoid rewriting with unique ports, this should ensure that a call can be received within two minutes after a router restart.

Note that some devices have different timeouts for registration retry that you may need to adjust.

If you still have trouble,

may be helpful.

Thanks, it helps, but what is your recomendation? Leave the “remove existing” as no or set it to yes? Can I force the phone to pick a port or can that only be done in the router?

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