Moved to pjsip, now there's no audio in softphones

I finally moved my FreePBX to pjsip. While all internally, local phones work, phones that are remote and outside of the local network aren’t transmitting audio to and from. In other words, they are mute – sort of speak. The soft phone correctly registers. They can dial and connect. Just no audio.

I figure that this would be a NAT/Firewall issue. But unlike SIP_Chan, I am unable to set NAT =YES and Force comedy and rport.

Googling, I tried to set under my device, advanced settings “Direct Media = No”, set only to use ulaw and alaw. but those didn’t work either.

The connection keeps reconnecting to as shown in the attached screenshot.

I would highly appreciate any help you can share.


My FreePBX is running in a VM for years.
Asterisk 16 LTS Certified
Freepbx 16.0.30
Running behind a firewall with port 5080 and RTP 10000-20000 open UDP.

The equivalent settings for pjsip extensions are RTP Symmetric, Rewrite Contact and Force rport .
However, these are all on by default. Confirm that for extension 100, all are set to Yes.

Two endpoints are trying to register as the same extension; each is knocking the other off. You can set Max Contacts to two or more to prevent that, though you should also find out why it’s happening.

72.143.221.61 is assigned to Rogers. Assuming that the extension is in Canada on Rogers cable, that’s probably correct. However, 35.197.16.246 is assigned to Google and is used for GCP (Google Cloud Platform). Does this make sense (you have a VPN server or test client there)? It might be a malicious connection, but since it was successfully registered, i.e. the attacker has the password, this seems unlikely unless your system was previously compromised. Turning on pjsip logger should show what is registering from there.

Please don’t post screenshots containing text. If it’s just a few lines, paste the text into your post, marked as code:

```
A log entry.
Another log entry.
```

Which will display as:

A log entry.
Another log entry.

For a longer log, paste it at pastebin.freepbx.org and post the link here.

Asterisk 16 is no longer supported and certified versions of Asterisk are only supported for people with support contracts, for Asterisk, rather than FreePBX, with Sangoma. You probably want the latest, non-certified, Asterisk 20.

All three settings are set to YES.

Two endpoints are trying to register as the same extension; each is knocking the other off. You can set Max Contacts to two or more to prevent that, though you should also find out why it’s happening.

72.143.221.61 is assigned to Rogers. Assuming that the extension is in Canada on Rogers cable, that’s probably correct. However, 35.197.16.246 is assigned to Google and is used for GCP (Google Cloud Platform). Does this make sense (you have a VPN server or test client there)? It might be a malicious connection, but since it was successfully registered, i.e. the attacker has the password, this seems unlikely unless your system was previously compromised. Turning on pjsip logger should show what is registering from there.

In my FreePBX configuration, I have one extension, in this case, 207. It is shared by two devices: 100 (Bria Softphone) and 207 (Sangoma S500). It would make sense that Bria soft phone is trying to connect given that I must login to the sofphone; it then retrieves my softphones configuration. My iPhone is on Fido which is part of Rogers.

Per your suggestion, I’ve also set Max Contacts on Device: 100, to 2. It had no effect.

Here’s the log file when I tried to use the Bria soft phone to do an echo test. Hope this give us more insights. The behaviour on the echo test is that there appears a connection, but no voice, which is the problem I’m having.

1410	[2023-02-06 10:37:58] VERBOSE[56461] res_pjsip_registrar.c: Added contact 'sip:[email protected]:63657;rinstance=892c50c58cc6b051;x-ast-orig-host=192.168.0.1:50000' to AOR '100' with expiration of 3600 seconds	
1411	[2023-02-06 10:37:58] VERBOSE[56461] res_pjsip_registrar.c: Removed contact 'sip:[email protected]:60524;rinstance=be1ed6cd533e23f0' from AOR '100' due to remove existing	
1412	[2023-02-06 10:37:58] VERBOSE[33214] res_pjsip/pjsip_options.c: Contact 100/sip:[email protected]:60524;rinstance=be1ed6cd533e23f0 has been deleted	
1413	[2023-02-06 10:37:58] VERBOSE[56461] res_pjsip_registrar.c: Removed contact 'sip:[email protected]:63657;rinstance=892c50c58cc6b051;x-ast-orig-host=192.168.0.1:50000' from AOR '100' due to request	
1414	[2023-02-06 10:37:58] VERBOSE[56461] res_pjsip/pjsip_options.c: Contact 100/sip:[email protected]:63657;rinstance=892c50c58cc6b051;x-ast-orig-host=192.168.0.1:50000 has been deleted	
1415	[2023-02-06 10:37:59] VERBOSE[56461] res_pjsip_registrar.c: Added contact 'sip:[email protected]:63657;rinstance=892c50c58cc6b051' to AOR '100' with expiration of 3600 seconds	
1416	[2023-02-06 10:37:59] VERBOSE[56461] res_pjsip/pjsip_configuration.c: Endpoint 100 is now Reachable	
1417	[2023-02-06 10:37:59] VERBOSE[56461] res_pjsip/pjsip_options.c: Contact 100/sip:[email protected]:63657;rinstance=892c50c58cc6b051 is now Reachable. RTT: 98.919 msec	
1418	[2023-02-06 10:38:40] VERBOSE[56461] pbx_variables.c: Setting global variable 'SIPDOMAIN' to 'sip.medullas.com'	
1419	[2023-02-06 10:38:40] VERBOSE[56461] netsock2.c: Using SIP RTP Audio TOS bits 184	
1420	[2023-02-06 10:38:40] VERBOSE[56461] netsock2.c: Using SIP RTP Audio TOS bits 184 in TCLASS field.	
1421	[2023-02-06 10:38:40] VERBOSE[56461] netsock2.c: Using SIP RTP Audio CoS mark 5	
1422	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [*43@from-internal:1] Set("PJSIP/100-00000003", "CONNECTEDLINE(name-charset,i)=utf8") in new stack	
1423	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [*43@from-internal:2] Set("PJSIP/100-00000003", "CONNECTEDLINE(name,i)=Echo Test") in new stack	
1424	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [*43@from-internal:3] Set("PJSIP/100-00000003", "CONNECTEDLINE(num,i)=*43") in new stack	
1425	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [*43@from-internal:4] Answer("PJSIP/100-00000003", "") in new stack	
1426	[2023-02-06 10:38:40] VERBOSE[56430] chan_sip.c: Extension Changed *992*9*207[restapps-device-hints] new state InUse for Notify User 207	
1427	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [*43@from-internal:5] Macro("PJSIP/100-00000003", "user-callerid,") in new stack	
1428	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:1] Set("PJSIP/100-00000003", "TOUCH_MONITOR=1675708720.45") in new stack	
1429	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:2] Set("PJSIP/100-00000003", "CHANCONTEXT=") in new stack	
1430	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:3] Progress("PJSIP/100-00000003", "") in new stack	
1431	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:4] Set("PJSIP/100-00000003", "CHANCONTEXT=") in new stack	
1432	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:5] Set("PJSIP/100-00000003", "CHANEXTENCONTEXT=100-00000003") in new stack	
1433	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:6] Set("PJSIP/100-00000003", "CHANEXTEN=100-00000003") in new stack	
1434	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:7] Set("PJSIP/100-00000003", "CALLERID(number)=100") in new stack	
1435	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:8] Set("PJSIP/100-00000003", "AMPUSER=100") in new stack	
1436	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:9] Set("PJSIP/100-00000003", "HOTDESCKCHAN=100-00000003") in new stack	
1437	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:10] Set("PJSIP/100-00000003", "HOTDESKEXTEN=100") in new stack	
1438	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:11] Set("PJSIP/100-00000003", "HOTDESKCALL=0") in new stack	
1439	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:12] ExecIf("PJSIP/100-00000003", "0?Set(HOTDESKCALL=1)") in new stack	
1440	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:13] ExecIf("PJSIP/100-00000003", "0?Set(CALLERID(name)=)") in new stack	
1441	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:14] GotoIf("PJSIP/100-00000003", "0?report") in new stack	
1442	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:15] ExecIf("PJSIP/100-00000003", "1?Set(REALCALLERIDNUM=100)") in new stack	
1443	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:16] Set("PJSIP/100-00000003", "AMPUSER=207") in new stack	
1444	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:17] GotoIf("PJSIP/100-00000003", "0?limit") in new stack	
1445	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:18] Set("PJSIP/100-00000003", "AMPUSERCIDNAME=Ronny Ko") in new stack	
1446	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:19] ExecIf("PJSIP/100-00000003", "0?Set(__CIDMASQUERADING=TRUE)") in new stack	
1447	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:20] GotoIf("PJSIP/100-00000003", "0?report") in new stack	
1448	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:21] Set("PJSIP/100-00000003", "AMPUSERCID=207") in new stack	
1449	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:22] Set("PJSIP/100-00000003", "__DIAL_OPTIONS=HhTtr") in new stack	
1450	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:23] Set("PJSIP/100-00000003", "CALLERID(all)="Ronny Ko" <207>") in new stack	
1451	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:24] ExecIf("PJSIP/100-00000003", "0?Set(CUSDIAL=)") in new stack	
1452	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:25] ExecIf("PJSIP/100-00000003", "0?Set(CALLERID(all)="Ronny Ko" <207>)") in new stack	
1453	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:26] GotoIf("PJSIP/100-00000003", "0?limit") in new stack	
1454	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:27] ExecIf("PJSIP/100-00000003", "0?Set(GROUP(concurrency_limit)=207)") in new stack	
1455	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:28] ExecIf("PJSIP/100-00000003", "0?Set(CHANNEL(language)=)") in new stack	
1456	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:29] NoOp("PJSIP/100-00000003", "Macro Depth is 1") in new stack	
1457	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:30] GotoIf("PJSIP/100-00000003", "1?report2:macroerror") in new stack	
1458	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx_builtins.c: Goto (macro-user-callerid,s,31)	
1459	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:31] GotoIf("PJSIP/100-00000003", "0?continue") in new stack	
1460	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:32] ExecIf("PJSIP/100-00000003", "1?Set(__CALLEE_ACCOUNCODE=)") in new stack	
1461	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:33] Set("PJSIP/100-00000003", "__TTL=64") in new stack	
1462	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:34] GotoIf("PJSIP/100-00000003", "1?continue") in new stack	
1463	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx_builtins.c: Goto (macro-user-callerid,s,50)	
1464	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:50] Set("PJSIP/100-00000003", "CALLERID(number)=207") in new stack	
1465	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:51] Set("PJSIP/100-00000003", "CALLERID(name)=Ronny Ko") in new stack	
1466	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:52] GotoIf("PJSIP/100-00000003", "0?cnum") in new stack	
1467	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:53] Set("PJSIP/100-00000003", "CDR(cnam)=Ronny Ko") in new stack	
1468	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:54] Set("PJSIP/100-00000003", "CDR(cnum)=207") in new stack	
1469	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [s@macro-user-callerid:55] Set("PJSIP/100-00000003", "CHANNEL(language)=en") in new stack	
1470	[2023-02-06 10:38:40] VERBOSE[33441][C-00000006] pbx.c: Executing [*43@from-internal:6] Wait("PJSIP/100-00000003", "1") in new stack	
1471	[2023-02-06 10:38:41] VERBOSE[33441][C-00000006] pbx.c: Executing [*43@from-internal:7] BackGround("PJSIP/100-00000003", "demo-echotest,,,app-echo-test-echo") in new stack	
1472	[2023-02-06 10:38:41] VERBOSE[33441][C-00000006] file.c: <PJSIP/100-00000003> Playing 'demo-echotest.alaw' (language 'en')

AFAIK, ‘device and user mode’ is not properly supported in FreePBX and I suggest that you don’t use it.
However, two or more devices can register to the same PBX extension, by setting Max Contacts high enough; I recommend 4 for your case. I believe that Bria is set up to use push notifications (a good thing but you might want to turn it off for testing) and the registrations you are seeing from GCP are from the Bria push server. If extension 207 shows a Max Contacts field, setting that higher may fix the connection flapping, without having to undo device and user mode.

For the audio issue, it appears that pjsip logger was not on in your log. At the Asterisk command prompt (not a shell prompt), type
pjsip set logger on
and you should see
PJSIP Logging enabled
Then make your test call again and paste the new log.

Here’s the log file after changing the Max Contact field to 4. Logging off Bria, re-login back, and run another echo test. The result is unchanged.

Line 102:
Contact: <sip:172.67.168.46:5080>
and line 112:
c=IN IP4 104.21.25.230
are both presenting addresses related to your web server (hosted at or proxied by Cloudflare)
instead of the correct address on Telus fiber (I assume that this is an on-site PBX).

Did you accidentally put ‘medullas.com’ instead of ‘sip.medullas.com’ in your PBX configuration? Based on what you have told us so far, ‘medullas.com’ should not appear anywhere.

In Asterisk SIP Settings, on the chan_pjsip tab, the External IP Address and Local network fields for the various transports should probably be left blank (please explain if you feel otherwise). On the General SIP Settings tab, check the settings for External Address and Local Networks . Clicking Detect Network Settings will probably create the correct values. If you change these, after Submit and Apply config you must restart Asterisk.

If you still have trouble, paste a new log.

I’m glad to share that the Echo test now works!
You’re right, sip.medullas.com is the correct one rather than medullas.com. The only change that I made was under asterisk sip settings → Chan pjsip and I removed the local network ip address under 0.0.0.0 udp. then I was able to do the echo test.

Unfortunately, the device isn’t able to dial out (meaning any number outside). FreePBX voice prompt says “All Circuits are Busy now. Please try your call again later.” This issue could be related to the fact that Bria softphone disconnects (timed out). Under old chan_sip, disconnections were rare. It tried to re-register so many times that the responsive firewall blocked it.

The most recent log seems to be just part of a reload and has no call or SIP trace.

We’re making progress but still issues:

I followed your suggestions. For some reason, I left the project for 2 hours. I returned to try again. I was able to successfully do:

  1. Echo test (success)
  2. outgoing calls to any mobile/landline (success)
  3. incoming calls (failed) - the softphone isn’t able to maintain a stable connection with FreePBX. I left the iPhone alone. the phone screen turned off. I asked for someone to call my phone. Only the deskphone rang but not the softphone. You can see the disconnections by the softphone in the logs. At Bria’s, Keep Alive is set to enabled.

What provision did you make for a push server for the iPhone? iPhones will put VoIP apps to sleep if not on a call, and, unlike Android, there is no way to override this. You have to use a push service to wake up the app before it can handle an incoming call.

When we were using chan_sip, there was no disconnection even when the iPhone screen was off. What’s different with chan_pjsip?

On the Bria iPhone app, push notification is Enabled. Not sure if this is the same as “push server”

Other Push service are:
Use push notifications {enabled}
registration mode: single device takeover
NAT emulation {enabled}
SIP proxy {empty}
Insert Instance {disabled}
Disable Hash Token {disabled}
Auto send 180 ring {disabled}
Disable override domain {disabled}
Single Device Governed {disabled}
Push Server refresh Interval {3600} (I assume it’s seconds)

There’s a feature to "test push service} → when I press, it says “push test passed”.

Do any of these need to be changed?

I have undone all this hard work by all of us by restoring a snapshot. The reason is because no one could dial out anymore. It was working before today. That’s a very serious as it affects us all.

The iPhone issue was pretty small in comparison.

Hence, we have restored everything and I"ll just have to live with the constant bots trying to authenticate or find another solutions. If you have another solution, let me know.

For some reason, going back to the snapshot, Bria for iPhone started to ring again when the screen was locked.

Yes, chan_sip gets no more support but it works. I’ll stick to that.

Thank you @Stewart1 for your insights and knowledge.

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