Grandstream, Asterisk, and PJSIP. Are they compatible?

I’m going to ask one more time. Go into Settings → Asterisk SIP Settings → Chan_PJSIP tab. Look as see what the UDP port is listed as in the transports.

Then you cannot use 5061 for Chan_PJSIP because Chan_SIP is using it. This is maybe why you’re getting failures; you’re trying to connect to Chan_SIP’s TLS port based on that statement.

You need to confirm 100% what port Chan_PJSIP is listening on. Go look.

OK, so maybe the problem is that my system has been in use long enough that it’s using the “old” ports, 5060 and 5061 for CHAN_SIP while new systems assume it’s 5160 and 5161.

I checked AGAIN and my system has CHAN-PJSIP as port 5061.
I checked AGAIN and my system has CHAN_SIP as port 5060 and TLS at 5061

So yes, it appears I can’t use 5060 for PJSIP as it’s in use by CHAN-SIP. Since 5160 and 5161 aren’t in use anywhere I could use those ports however that would make my system using opposite ports as new installs which could be confusing later. Would have been nice if PJSIP would have use new ports instead of using ports used by CHAN_SIP on existing systems.

1 Like

My opinion is the best way to go from chan_sip to pjsip is all-in, cold turkey. Schedule a little downtime, reconfigure FreePBX so that chan_sip is fully disabled and pjsip is using the SAME PORTS as chan_sip was, and then run the “migrate to pjsip” script to change all your extensions over at once.

Having two active SIP drivers with different ports is a headache, as you are currently experiencing.

Alright. This is beyond simple. You ended up with conflicting ports being bound. You go into the Chan_PJSIP tab in the Asterisk SIP Settings and you change the bind port for Chan_PJSIP to 5160. This will require an fwconsole restart to reload the transport updates. Then you go into your phone and set the port to 5160.

This hasn’t been about a phone not allowing IP:port or Chan_PJSIP not working. This is the PBX having conflicting settings on it. This is probably the same issue that the other poster is having too.

FreePBX has been using Chan_PJSIP has the default SIP driver since before v14. That also means that 5060 and 5061 are bound to it with Chan_SIP being bound to 5160/5161 as I previously mentioned. Before that when Chan_SIP was the primary, it was swapped.

To be clear on this: Chan_PJSIP has always been bound to separate ports than Chan_SIP in FreePBX. If it wasn’t, it would never work. This is a case of a very old system being put through numerous system updates and version updates without being reviewed as to how those updates may have changed things or if your system is using more current “default” settings.

At some point an 8-year-old (plus) setup that has been updated as much as this needs to make sure conflicts of older configs/settings/modules don’t interfere with the current versions.

I understand what you’re saying but the system isn’t THAT old. It was purchased from Sangoma in 2016 and the core settings were done by their techs. I added IVRs, extensions, etc. but things such as SIP ports were done by them. I do recall they had a hard time getting the Grandstream phones to work and tried several things before they found a working combination.

And I understand the system needs to use different ports for the two SIP methods but they way they left it, both methods are set to use 5061, one for TLS, which I don’t use, and one for PJSIP, which I’ve been unable to use.

I tried changing the ports so they don’t match in the two systems, and I set the phone to match the new PJSIP port that I just changed. I did a reboot on the system to insure the new ports took effect. However the phone would not register to the PBX. I changed everything back and rebooted again so the phone will connect again.

I can’t keep rebooting the system during working hours so I’m done for now but frankly, I don’t know what else to try anyway. The default TLS Port assignment is set to Chan SIP instead of PJSip but since the phone doesn’t have TLS settings… I don’t know what else to try.

Take a step back and just breathe. All you need to do is update Chan_PJSIP’s port to something that Chan_SIP is not using. That’s it.

As for this being something in 2016, the only logic I can see to cause this was that this system was setup and Chan_PJSIP was disabled since it wasn’t being used. This would have been done to limit any confusion or conflicts of a secondary SIP driver not in use. Makes total sense.

Disabling Chan_PJSIP just stops the configs from being built out and loading Chan_PJSIP. If down the road, like in 2022, you decided to try out Chan_PJSIP and re-enabled it. You then need to go into Chan_PJSIP and make it isn’t conflicting with your current setup.

Am I close to what happened? I’ve seen it plenty of times over the years. People turn off PJSIP, update Chan_SIP back to 5060/5061 then down the road turn PJSIP back on and have all sorts of conflicts because they didn’t reconfigure PJSIP.

Just to confirm, on your Grandstream phone the Sip Server is set as ‘your.pbx.url:nnnn’ your transport is UCP

Where nnnn is the port Asterisk is binding to for the protocol the extension is set to use, and your.pbx.url resolves to your PBX’ point of ingress.

(nnnn will default to 5050 in it’s absence.)

I agree with what you’re saying except that I wanted to do it on one phone first to be sure it worked because of how many issues I’ve had getting Grandstream to work with FreePBX in the past. I figured if the one phone worked then I’d go all-in on the others via the scrip. But since the one phone doesn’t seem to work, I’m hesitant to make it so no phones work, especially when I have low confidence in the backups.

Where would PJSIP get turned off? It isn’t set as the default TLS port assignment but I don’t see an on/off type option anywhere.

And I DID set the PJSIP port to a port not used anywhere else but that didn’t work.

Dicko, on the Grandstream phone the SIP Server is set to the IP, but no the port is not listed on that line. ie 192.168.12.1 and not 192.168.12.1:5160 . Yes I read in the general guide that most of the time they want the IP:Port but in the example listed in the phone GUI it has only the IP, not a port. And then there is a separate field under it where it asks for the port. Based on that it sounds like the Grandstream isn’t like “most” as referenced in the guide.

I suggest you try it :slight_smile:

Dicko,
You hit the nail on the head. I changed the server to IP:port and rebooted the phone and the phone registered. At least I assume it registered using PJsip instead of ChanSip. How can I tell?

I think you still dont understand. When Chan_SIP and Chan_PJSIP are both running they are both bound to separate TLS ports. Because they are two different services.

This is like have Apache and Nginx on the server and saying “But Nginx has 443 for TLS why doesnt this Apache site work with TLS on 443?” Because apache cant use 443 it would use something else.

If successfully registered it will be to the protocol and port running on your server, this will be true for each ‘acount’ on the GS be they udp tcp tls (or wss)

I understand they are two different services. And they are running on two different ports currently. The phone connected to FreePBX once I changed the server path to include the :5161 port. The phone still shows port 5060 in the Port field so I don’t know which service it’s connecting to, ChanSip or pjsip.

You said something about enabling pjsip and that’s still bugging me. If I’m on the Settings-Asterisk SIP Settings then the General SIP settings tab my system shows the Default TLS Port assignment to be Chan SIP. I can’t select PJSip. It says if the option isn’t available it’s because the protocol is not enabled. And that brings me back to your comment and my question, where would this get enabled/disabled? And if it’s currently disabled, that means my phone is still connecting via ChanSip and not PJSip.

Without actually seeing any debugs or traces I can’t tell you what is happening.

Don’t confuse the GS’s ‘local port’ with the actually used port.

I think that’s exactly what I was doing. I’ve set the IP to xxx.xxx.xx.x:5161 now and rebooted the phone. It connects, but I don’t know if it’s connecting via ChanSip or PJsip. Something BlazeStudios said about PJsip perhaps being disabled somewhere may be true. I don’t know where to look for that. Must be in a config file rather than in the GUI.

Under Advanced Settings there is a setting for the SIP Channel Drivers. A dropdown that lets you select Chan_PJSIP, Chan_SIP or Both. You said you had a Sangoma tech help you with this. Either that tech did a very poor job of setting up your PBX by not disabling Chan_PJSIP or reconfiguring the ports to not conflict. Or they set it up to use Chan_SIP as the primary, updated the ports for Chan_SIP to be 5060/5061 and disabled Chan_PJSIP.

I’m really hoping it was the later and not the former.