PJSIP and CHAN_SIP at the same time - Total failure

Ok so i have a testing and a production server.

Both are the same in the following.

Asterisk version - Asterisk 13.17.1
pbx-version - 10.13.66-17

Both servers are fully up to date with modules.

Now here is my scenario.

I have a location that historically has always been one phone one extension. Now some mobile users are going to be moving from one location to another. This made me want to enable PJSIP and move forward with connecting multiple endpoints to one extension.

On my testing server i set sip driver to both. And verified sip ports were as followed. chan_sip = 5060 & pjsip = 5061. After i set that up i noticed the server was not listening on 5061 via the following “lsof -i :5061” so natrually i figured asterisk did not read the config changes and needed to restart. So i issued a “fwconsole restart” and then i noticed that 5061 was working.

I went in and created an extension pjsip 2211.

I setup a Yealink T48G for that extension and it connected to 5061. Ok good. I increased the max contacts from 1 to 3 and then hit submit and apply.

I moved on to test with another T48G and it also registered. Ok good i called the extension and both phones rang. I launched X-Lite and it also registered and rang properly. Ok thats a good test.

I moved on to the production server

I made the same above changes and got to the point where i needed to issue the fwconsole restart command to restart asterisk. This is where things took a turn for the worst.

I logged into asterisk and seen the following.

[2018-01-02 22:32:22] NOTICE[6725]: res_pjsip/pjsip_distributor.c:649 log_failed_request: Request ‘REGISTER’ from ‘“3508” sip:[email protected]’ failed for ‘10.60.0.83:5060’ (callid: ebcee9967e600c0e) - No matching endpoint found
[2018-01-02 22:32:22] NOTICE[6725]: res_pjsip/pjsip_distributor.c:649 log_failed_request: Request ‘REGISTER’ from ‘“3508” sip:[email protected]’ failed for ‘10.60.0.83:5060’ (callid: ebcee9967e600c0e) - Failed to authenticate
[2018-01-02 22:32:22] NOTICE[6725]: res_pjsip/pjsip_distributor.c:649 log_failed_request: Request ‘REGISTER’ from ‘“6278” sip:[email protected]’ failed for ‘10.60.0.104:5060’ (callid: 9c58e3e03d63636b) - No matching endpoint found
[2018-01-02 22:32:22] NOTICE[6725]: res_pjsip/pjsip_distributor.c:649 log_failed_request: Request ‘REGISTER’ from ‘“6278” sip:[email protected]’ failed for ‘10.60.0.104:5060’ (callid: 9c58e3e03d63636b) - Failed to authenticate

So a ton of these errors about failing to register showed up. Now i am not sure why this happened.

It should still be taking chan_sip on 5060 not PJSIP. I verified that both ports were still active.

lsof -i :5061

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
asterisk 6612 asterisk 21u IPv4 233921269 0t0 UDP *:sip-tls

lsof -i :5060

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
asterisk 6612 asterisk 22u IPv4 233921274 0t0 UDP 192.168.XXX.XX8:sip

Any ideas or things i should look at.

Everything was down at this time trunks were not registering and all extensions were throwing failed to authenticate as if chan_sip was not even being attempted on 5060.

Thanks.

Probable cause highlighted above. Your phones are trying to register on 5060, but your PJ-SIP extensions are on 5061.

All extensions are still going to be CHAN_SIP only new extensions will be setup as PJSIP.

So why are these phones sending to 5060 and being denied or treated at CHAN_SIP?

Do i have to convert all extensions over to PJSIP? I didn’t need to do this on my testing server.

You perhaps have both chan_pjsip and tls on the same 5061. move tls somewhere else

How to i get chan sip to listen on all IP’s like pjsip shows in my lsof -i :5061

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
asterisk 6612 asterisk 21u IPv4 233921269 0t0 UDP *:sip-tls

On my testing server it shows

lsof -i :5060
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
asterisk 6612 asterisk 22u IPv4 233921274 0t0 UDP *:sip

You can see my chan_sip port above

Here is my pjsip port you can see both are different ports.

Ideas?

chan-sip can’t listen on all ports

I know i was wondering why it wasn’t listening on all IP’s.

I still am perplexed why this is failing.

I’ve cloned the production server and will work on that today but all settings match what is built on the testing server.

I doubt it is requiring a reboot.

Not sure if there is anything else to look at though.

Ok on the cloned server.

|o|Settings -> Advanced Settings – Change SIP Channel Driver to : both

|o|Settings -> Asterisk SIP Settings -> Chan PJSIP Settings – Verify the following settings|
||Allow Guests : No|
||Port to Listen On : 5061|
||Local network : Remove 10.60.0.0/24 leave blank|
|o|Settings -> Asterisk SIP Settings -> Chan SIP Settings – Verify the following settings|
||Bind Port : 5060|
||Override External IP : Remove 192.168.XXX.XX8 leave blank|

And then i issued
service asterisk restart

Now

lsof -i :5060

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
asterisk 6716 asterisk 19u IPv4 492617 0t0 UDP *:sip

lsof -i :5061

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
asterisk 6716 asterisk 16u IPv4 492606 0t0 UDP *:sip-tls

And then i issued a
fwconsole restart

And everythng is still working.

But do you see where its listening on *:sip and *:sip-tls that is what my testing server shows and i was able to flip two phones over to chan_sip and i created a new extension and registered x-lite to PJSIP 5061.

I will be doing this work tonight.

Fingers crossed. If all else fails I’ll reboot the server. That is the only difference between the clone in production is that the clone did a clean boot this morning.

have you changed the tls port in chan-sip yet?

I had an issue with my yealink phones doing something similar to this. 5060 was chan_sip and the yealink assumed 5061 was chan_sip TLS. I moved PjSIP to a completely different port all by itself, updated, the phone, worked. Not sure if that’s the issue here but its worth a look if you can’t figure it out.

My TLS Bind Port is blank. On all three servers in this scenario.

My issue is i have Aastra 57i phones as a majority of this location.

lsof -i :5061
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
asterisk 6716 asterisk 16u IPv4 492606 0t0 UDP *:sip-tls

change it to 39123, anything above 1024 and not between 1000 and 20000

If you have a newer firmaware on the 57 , use TCP in preference , enable it in FreePBX

Ok so this is so frustrating.

Its a problem with chan_sip.

Any time that i enable pjsip chan_sip starts to listen on the IP:sip and no longer *:sip

On my clone it stays *:sip

I just made my changes to match the clone and again it shows 192.168.XXX.XX8:sip

I can change pjsip above 5061 but i have no idea why that will affect chan_sip registration? or listening bind address.

So again after restarting asterisk everything tries pjsip on 5060. back to the drawing board.

i changed pjsip to 39123

lsof -i :39123

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
asterisk 30891 asterisk 13u IPv4 613236 0t0 UDP *:39123

lsof -i :5060

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
asterisk 30891 asterisk 19u IPv4 613246 0t0 UDP 192.168.3.38:sip

service asterisk restart

Stopping safe_asterisk: [ OK ]
Shutting down asterisk: [ OK ]
Starting asterisk: [ OK ]

lsof -i :5060

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
asterisk 32321 asterisk 18u IPv4 619107 0t0 UDP *:sip

lsof -i :39123

again all extensions were like nope nope nope

[2018-01-04 22:40:38] ERROR[28773]: chan_sip.c:4274 __sip_reliable_xmit: Serious Network Trouble; __sip_xmit returns error for pkt data

not sure what that means but no idea why this is so terrible for me

If I where you, and until I understood it all l just would disable chan-pjsip, it will then not get in the way of tls or sip on 5060/5061

Then set sip to listen on 5060, that has generaaly worked fir tears

This is what a ‘normal’ system looks like when both drivers are enabled:

# asterisk -x " sip show settings" | grep Bind
  UDP Bindaddress:        0.0.0.0:5060
  TCP SIP Bindaddress:    0.0.0.0:5060
  TLS SIP Bindaddress:    0.0.0.0:5061
  RTP Bindaddress:        Disabled
# asterisk -x "pjsip show transports"
  Transport:  0.0.0.0-tcp               tcp      0      0  0.0.0.0:5160
  Transport:  0.0.0.0-tls               tls      0      0  0.0.0.0:5161
  Transport:  0.0.0.0-udp               udp      0      0  0.0.0.0:5160

port bindings for TCP and UDP can be shared, but all others must be unique. The bind address is as set in Asterisk SIP Settings, and generally you want that field unset.

Ok so where do you think i would find the configuration option if

UDP Bindaddress: 192.168.XXX.XX8:5060

instead of what you show or what i see on my known working servers

UDP Bindaddress: 0.0.0.0:5060

If i do not have pjip enabled the results from asterisk -x “sip show settings” | grep Bind are as seen

asterisk -x " sip show settings" | grep Bind

UDP Bindaddress: 0.0.0.0:5060
TCP SIP Bindaddress: Disabled
TLS SIP Bindaddress: Disabled

Bindings (port and address) are all as set in Settings, Asterisk SIP Settings, separate tab for each driver. Submit settings on each page one at a time. Binding changes in the GUI require and Asterisk restart.

Ok so heres my next option

Settings > Advanced Settings
Change sip driver to both
Submit
Apply Config

Settings > Asterisk SIP Settings
verify the following
Chan SIP Settings
Bind Port : 5060
TLS Bind Port : (Blank not using TLS)
Enable TCP : No
Submit
Apply Config

Chan PJSIP Settings
under 0.0.0.0 (udp)
Port to Listen On : 5160
Submit
Apply Config

via ssh

service asterisk restart

log into asterisk via cli

asterisk -vvvvr

now this is where everything goes to hell for me on my production server. I see all of the extensions trying to register pjsip on 5060. Then fail2ban goes off and i get the network trouble errors.

See this should never happen but i have this feeling that chan_sip is just failing now i don’t know how PJSIP is being detected for the extensions that try to register on 5060 because that port was always 5061 but i am changing that to 5160 tonight. we will see.

Lorne any other suggetions other then what i outlined above? I will run the commands you pointed out looking for bind and checking transports for pjsip.

Last night i was looking around trying to see if for some reason the 192 address was assocated with 5060 in /etc/astersisk/

I was running grep -r “5060” . and again 192. was not in anything so i have no idea why the lsof was showing that specific address as a bind address but we will see.

Never do this when logged in as root, as the service starts with the wrong user. Restart Asterisk with:

fwconsole restart
1 Like