Translate fushionpbx gateway or MicroSip configurations to a freepbx pjsip trunk

Hi all. My pjsip trunk pointed to my isp is always receiving 480 error (Hllm query failed) or 408 (Server Busy).

Server ims.abc.com
Proxy 221.x.y.z
User +123456 (13 digits led by +, containing country code, area code, same as my full length phone number)
Password passw0rd
WanIP 100.115.77.19
Gateway 100.115.77.1

That’s all I have from my provider.

I’ve successfully registered my account using microsip, pjsua, and fusionpbx.
************TEST1 [MicroSIP Account Settings]
It runs on my laptop(ip 100.115.77.19, gateway 100.115.77.1) directly connected to ims network without NAT, and I can call out and call in.

Server: ims.abc.com
Proxy: 221.x.y.z
User: +123456
Domain: ims.abc.com
Login: [email protected]
Password: passw0rd

************TEST2 [PJSUA reg logs]
It runs without nat too, and can reg successfully.

REGISTER sip:ims.abc.com SIP/2.0
Via: SIP/2.0/UDP 100.115.77.19:5060;rport;branch=z9hG4bKPj88b1a7db-5a8c-4b6b-85fe-51c3b6c3e93a
Route: <sip:211.x.y.z;lr>
Max-Forwards: 70
From: <sip:[email protected]>;tag=bf17cc11-0d96-4403-a308-71a947ceb098
To: <sip:[email protected]>
Call-ID: d09515e3-b511-42d0-a669-1c183aa8199a
CSeq: 52765 REGISTER
User-Agent: PJSUA v2.13.1 Linux-5.10.0.22/x86_64/glibc-2.31
Contact: <sip:[email protected]:5060;ob>
Expires: 1800
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length:  0


--end msg--
15:56:50.358           pjsua_core.c  .RX 498 bytes Response msg 401/REGISTER/cseq=52765 (rdata0x7f483c001bc8) from UDP 211.x.y.z:5060:
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 100.115.77.19:5060;branch=z9hG4bKPj88b1a7db-5a8c-4b6b-85fe-51c3b6c3e93a;received=100.115.77.19;rport=5060
Call-ID: d09515e3-b511-42d0-a669-1c183aa8199a
From: <sip:[email protected]>;tag=bf17cc11-0d96-4403-a308-71a947ceb098
To: <sip:[email protected]>;tag=nsunpavt
CSeq: 52765 REGISTER
WWW-Authenticate: Digest realm="ims.abc.com",nonce="2PQNPf+tl+mLOYdhoR7erQ==",algorithm=MD5
Content-Length: 0


--end msg--
15:56:50.358      sip_auth_client.c  ...Digest algorithm is "MD5"
15:56:50.358           pjsua_core.c  ....TX 883 bytes Request msg REGISTER/cseq=52766 (tdta0x7f483c003fb8) to UDP 211.x.y.z:5060:

REGISTER sip:ims.abc.com SIP/2.0
Via: SIP/2.0/UDP 100.115.77.19:5060;rport;branch=z9hG4bKPj3452d63f-8010-4d8a-921b-73cbad3c68ba
Route: <sip:211.x.y.z;lr>
Max-Forwards: 70
From: <sip:[email protected]>;tag=bf17cc11-0d96-4403-a308-71a947ceb098
To: <sip:[email protected]>
Call-ID: d09515e3-b511-42d0-a669-1c183aa8199a
CSeq: 52766 REGISTER
User-Agent: PJSUA v2.13.1 Linux-5.10.0.22/x86_64/glibc-2.31
Contact: <sip:[email protected]:5060;ob>
Expires: 1800
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Authorization: Digest username="[email protected]", realm="ims.abc.com", nonce="2PQNPf+tl+mLOYdhoR7erQ==", uri="sip:ims.abc.com", response="e1695fe87662315692b72b1372a5f357", algorithm=MD5
Content-Length:  0


--end msg--
15:56:50.617           pjsua_core.c  .RX 571 bytes Response msg 200/REGISTER/cseq=52766 (rdata0x7f483c001bc8) from UDP 211.x.y.z:5060:
SIP/2.0 200 OK
Via: SIP/2.0/UDP 100.115.77.19:5060;branch=z9hG4bKPj3452d63f-8010-4d8a-921b-73cbad3c68ba;received=100.115.77.19;rport=5060
Call-ID: d09515e3-b511-42d0-a669-1c183aa8199a
From: <sip:[email protected]>;tag=bf17cc11-0d96-4403-a308-71a947ceb098
To: <sip:[email protected]>;tag=qdsr9paq
CSeq: 52766 REGISTER
Accept-Resource-Priority: wps.4
P-Associated-URI: <sip:[email protected]>,<tel:+123456>
Contact: <sip:[email protected]:5060;ob>;q=1;expires=1800
Content-Length: 0

************TEST3 [FusionPBX gateway reg logs]
My fusionpbx server is deployed behind NAT. I have configured Port Forward on firewall. Gateway can register successfully, too.

LAN IP: 192.168.0.3/24
GATEWAY: 192.168.0.1

send 675 bytes to udp/[221.x.y.z]:5060 at 16:49:46.306421:
------------------------------------------------------------------------
REGISTER sip:ims.abc.com;transport=udp SIP/2.0
Via: SIP/2.0/UDP 100.115.77.19:5080;rport;branch=z9hG4bKKUK3maKBg0myK
Max-Forwards: 70
From: <sip:[email protected]>;tag=H44vN1HHZ5D2Q
To: <sip:[email protected]>
Call-ID: 8054a079-433d-488e-b1df-567c7ff49020
CSeq: 70972501 REGISTER
Contact: <sip:[email protected]:5080;transport=udp;gw=39c711ce-9252-4250-8d87-d382e0b46f1b>
Expires: 3600
User-Agent: FreeSWITCH-mod_sofia/1.10.9-release~64bit
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY
Supported: path, replaces
Content-Length: 0


recv 454 bytes from udp/[221.x.y.z]:5060 at 16:49:46.516919:
------------------------------------------------------------------------
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 100.115.77.19:5080;branch=z9hG4bKKUK3maKBg0myK;received=100.115.77.19;rport=19957
Call-ID: 8054a079-433d-488e-b1df-567c7ff49020
From: <sip:[email protected]>;tag=H44vN1HHZ5D2Q
To: <sip:[email protected]>;tag=q3qm93pp
CSeq: 70972501 REGISTER
WWW-Authenticate: Digest realm="ims.abc.com",nonce="Pj3uT3x9gdCoMhOEetCnJg==",algorithm=MD5
Content-Length: 0


send 921 bytes to udp/[221.x.y.z]:5060 at 16:49:46.543289:
------------------------------------------------------------------------
REGISTER sip:ims.abc.com;transport=udp SIP/2.0
Via: SIP/2.0/UDP 100.115.77.19:5080;rport;branch=z9hG4bKm4cvp53eD9aHF
Max-Forwards: 70
From: <sip:[email protected]>;tag=H44vN1HHZ5D2Q
To: <sip:[email protected]>
Call-ID: 8054a079-433d-488e-b1df-567c7ff49020
CSeq: 70972502 REGISTER
Contact: <sip:[email protected]:5080;transport=udp;gw=39c711ce-9252-4250-8d87-d382e0b46f1b>
Expires: 3600
User-Agent: FreeSWITCH-mod_sofia/1.10.9-release~64bit
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY
Supported: path, replaces
Authorization: Digest username="[email protected]", realm="ims.abc.com", nonce="Pj3uT3x9gdCoMhOEetCnJg==", algorithm=MD5, uri="sip:ims.abc.com;transport=udp", response="d890e57d34589fa5f3b85477f31c8b6e"
Content-Length: 0


recv 603 bytes from udp/[221.x.y.z]:5060 at 16:49:46.734902:
------------------------------------------------------------------------
SIP/2.0 200 OK
Via: SIP/2.0/UDP 100.115.77.19:5080;branch=z9hG4bKm4cvp53eD9aHF;received=100.115.77.19;rport=19957
Call-ID: 8054a079-433d-488e-b1df-567c7ff49020
From: <sip:[email protected]>;tag=H44vN1HHZ5D2Q
To: <sip:[email protected]>;tag=p6qtvucg
CSeq: 70972502 REGISTER
Accept-Resource-Priority: wps.4
P-Associated-URI: <sip:[email protected]>,<tel:+123456>
Contact: <sip:[email protected]:5080;transport=udp;gw=39c711ce-9252-4250-8d87-d382e0b46f1b>;q=1;expires=3600
Content-Length: 0

*******************[FreePBX]
My freepbx server is placed the same network location as fusionpbx (single network adapter, behind NAT)

LAN IP: 192.168.0.4/24
GATEWAY: 192.168.0.1

But my pjsip trunk in freepbx can’t register.

2023/08/03 09:42:34.663138 192.168.0.4:5060 -> 221.x.y.z:5060
REGISTER sip:ims.abc.com:5060 SIP/2.0
Via: SIP/2.0/UDP 100.115.77.19:5060;rport;branch=z9hG4bKPj5371102e-3ca9-452a-b3a0-904e9febd65c
Route: <sip:221.x.y.z;lr>
From: <sip:[email protected]>;tag=02b124f9-f2e0-42c2-bb01-e5829dc9327e
To: <sip:[email protected]>
Call-ID: ebc74229-3593-421f-8496-02f28af7f4c2
CSeq: 28330 REGISTER
Contact: <sip:[email protected]:5060>
Expires: 1800
Allow: OPTIONS, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, MESSAGE, REFER
Max-Forwards: 70
User-Agent: Asterisk/16.24.1
Content-Length:  0



2023/08/03 09:42:34.710841 221.x.y.z:5060 -> 192.168.0.4:5060
SIP/2.0 480 Temporarily Unavailable
Via: SIP/2.0/UDP 100.115.77.19:5060;branch=z9hG4bKPj5371102e-3ca9-452a-b3a0-904e9febd65c;received=100.115.77.19;rport=5060
Call-ID: ebc74229-3593-421f-8496-02f28af7f4c2
From: <sip:[email protected]>;tag=02b124f9-f2e0-42c2-bb01-e5829dc9327e
To: <sip:[email protected]>;tag=2eggccyl
CSeq: 28330 REGISTER
Warning: 399 P.20.102.js.chinamobile.com "SS230000F133L3358S0E0[00001] Hllm query failed"
Content-Length: 0

I compared these logs with previous testing logs. They almost have same parameters except Contact parameter in pjsua ends with ;ob, and Route parameter is hidden in FusionPBX.

I’m a very beginner. Can someone tell me where I should start my troubleshooting? Thanks a lot.

FusionPBX gateway settings (gateway can register successfully)

FreePBX trunk settings (can’t register)

Try setting Outbound Proxy to
sip:221.x.y.z\;lr\;hide
and retest. If no luck, post new REGISTER and resulting response(s).

Can’t see Route line now. But I get the same response.

2023/08/03 12:29:28.185576 192.168.0.4:5060 -> 221.x.y.z:5060
REGISTER sip:ims.abc.com:5060 SIP/2.0
Via: SIP/2.0/UDP 100.115.77.19:5060;rport;branch=z9hG4bKPj6b39eff9-f788-4f59-8817-ec63dee986c7
From: <sip:[email protected]>;tag=7e10f2d4-dc36-475e-a902-b92600d5ac86
To: <sip:[email protected]>
Call-ID: e5105ed0-bec3-45be-be66-6105bc813c22
CSeq: 1729 REGISTER
Contact: <sip:[email protected]:5060>
Expires: 1800
Allow: OPTIONS, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, MESSAGE, REFER
Max-Forwards: 70
User-Agent: Asterisk/16.24.1
Content-Length:  0


2023/08/03 12:29:28.265488 221.x.y.z:5060 -> 192.168.0.4:5060
SIP/2.0 480 Temporarily Unavailable
Via: SIP/2.0/UDP 100.115.77.19:5060;branch=z9hG4bKPj6b39eff9-f788-4f59-8817-ec63dee986c7;received=100.115.77.19;rport=5060
Call-ID: e5105ed0-bec3-45be-be66-6105bc813c22
From: <sip:[email protected]>;tag=7e10f2d4-dc36-475e-a902-b92600d5ac86
To: <sip:[email protected]>;tag=fefcdndd
CSeq: 1729 REGISTER
Warning: 399 P.20.102.abc.com "SS230000F133L3358S0E0[00001] Hllm query failed"
Content-Length: 0

PJSUA doesn’t hide Route neither, and it can register correctly. Maybe it doesn’t affect whether ;hide added or not?

I’m not sure if Asterisk SIP Setting details useful for troubleshooting.
General SIP Setting

SIP Settings(chan_pjsip)

Client URI: sip:[email protected]
Server URI: sip:ims.abc.com
AOR Contact: sip:[email protected]:5060
Match(Permit): 100.115.77.1,221.x.y.z,192.168.0.0/24
(They’re gateway of wan, outbound proxy, and lan network)

After struggling against different parameters, this trunk can communicate successfully with provider, but not totally I think. :frowning:
Calls sent to specific providers are always getting TRUNK Dial failed due to CHANUNAVAIL HANGUPCAUSE: 127 - failing through to other trunks errors returned.

This is a generic error that the provider rejected the call for an ‘unspecified’ cause. There is likely more information in the SIP response code, and there may be a Warning header with a more detailed error. Look at the SIP trace for details. Also, please report whether your other clients (FusionPBX and softphone) are also getting this error.

This should be the default value (I assume sip:[email protected]) so if you set the value blank nothing should change.

This is not the default value (which did work with your other clients), so I suspect that the server doesn’t care, but there is a SIP ALG or proxy in the path that was altering traffic and causing registration to fail; changing this value somehow eliminated the undesired alteration. You might check whether more closely emulating FusionPBX (using port 5080, changing User-Agent, etc.) fixes the problem.

Again, this should be the default value; setting it blank should not change the REGISTER request sent out.

Match(Permit) is (only) used to associate an incoming call to a specific trunk. It does not affect registration or outbound calls in any way. In most cases it can be left blank, because incoming calls will always be sent from the same IP address and port to which you registered. In some cases, the provider sends calls from multiple servers (load balancing and/or failover), so you need to list all the addresses from which the provider can send calls. It makes no sense to list any of your own addresses here.

IMO http://baodoc.frp.bao-server.club:22080/project/41/570/ and asterisk中eyebeam与移动的IMS帐号对接 - 芽滴滴 - 博客园 represent valid settings. Do you agree?

Thanks for your reply. Realm is supported by FusionPBX(freeswitch), while FreePBX pjsip trunk doesn’t. I know almost nothing about SIP, especially parameters’ meaning and how they affect exactly when communicating. So I have to try a lot of combinations blindly.
Client URL/ Server URI/ AOR Concat is my lucky final attempt for resolving lacking Realm issue. But I’ve no idea why :sweat_smile:

TRUNK Dial failed due to CHANUNAVAIL HANGUPCAUSE: 127 - failing through to other trunks issue is solved, too. Incoming calls never fail. But when calling LTE phones(I’m not sure. Maybe specific provider.), it’s always rejected. It looks like be caused by G729 codec negotiation. I guess it’s probably related of mismatch maxptime value. If I enable Opus insted of G729, everything goes fine.

Thank you again for your response.

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