Need help setting up FreePBX with SIP Trunk

Hi,

I only just started learning FreePBX.
I have FreePBX 17 installed on a computer. The provider is an ISP, and they didn’t provide much information regarding setting up the SIP trunk, but I managed to find someone set it up from the same provider in MicroSIP and I managed to copy it, and it works in MicroSIP. I tried to set it up in FreePBX but only the inbound calls are working, the outbound call did not. I have setup my outbound route dial pattern to prepend 9 and dial pattern X. .

pjsip logs

[2024-11-13 18:21:22] VERBOSE[4898] res_pjsip_logger.c: <--- Transmitting SIP request (988 bytes) to UDP:10.225.0.1:5060 --->
INVITE sip:10.225.0.1:5060 SIP/2.0
Via: SIP/2.0/UDP 10.194.7.168:5060;rport;branch=z9hG4bKPj153e29ad-95ec-45f5-8aa3-b220cd949498
From: <sip:[email protected]>;tag=8f155367-5d83-4d6b-b48e-de132cfecf79
To: <sip:[email protected]>
Contact: <sip:[email protected]:5060>
Call-ID: a1b6e518-c1c5-4c08-8b8e-6aacf55c9c41
CSeq: 18581 INVITE
Allow: OPTIONS, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, MESSAGE, INFO, REFER
Supported: 100rel, timer, replaces, norefersub, histinfo
Session-Expires: 1800
Min-SE: 90
Route: <sip:[email protected]:5060>
Max-Forwards: 70
User-Agent: FPBX-17.0.19.16(21.5.0)
Content-Type: application/sdp
Content-Length:   259

v=0
o=- 377526686 377526686 IN IP4 10.194.7.168
s=Asterisk
c=IN IP4 10.194.7.168
t=0 0
m=audio 17822 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:140
a=sendrecv

[2024-11-13 18:21:22] VERBOSE[1746] res_pjsip_logger.c: <--- Received SIP response (326 bytes) from UDP:10.225.0.1:5060 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.194.7.168:5060;branch=z9hG4bKPj153e29ad-95ec-45f5-8aa3-b220cd949498;rport=5060
Call-ID: a1b6e518-c1c5-4c08-8b8e-6aacf55c9c41
From: <sip:[email protected]>;tag=8f155367-5d83-4d6b-b48e-de132cfecf79
To: <sip:[email protected]>
CSeq: 18581 INVITE
Content-Length: 0


[2024-11-13 18:21:22] VERBOSE[1746] res_pjsip_logger.c: <--- Received SIP response (925 bytes) from UDP:10.225.0.1:5060 --->
SIP/2.0 183 Session Progress
Via: SIP/2.0/UDP 10.194.7.168:5060;branch=z9hG4bKPj153e29ad-95ec-45f5-8aa3-b220cd949498;rport=5060
Call-ID: a1b6e518-c1c5-4c08-8b8e-6aacf55c9c41
From: <sip:[email protected]>;tag=8f155367-5d83-4d6b-b48e-de132cfecf79
To: <sip:[email protected]>;tag=fqrt6i3g-CC-165
CSeq: 18581 INVITE
Allow: INVITE,ACK,OPTIONS,BYE,CANCEL,REGISTER,INFO,PRACK,SUBSCRIBE,NOTIFY,UPDATE,MESSAGE,UNSUBSCRIBE,REFER,PUBLISH
Contact: <sip:10.225.0.1:5060;Hpt=8f32_16;CxtId=3;TRC=ffffffff-ffffffff>
Require: 100rel
RSeq: 1
Reason: Q.850;cause=1;text="Unallocated number",SIP;cause=404
P-Early-Media: sendrecv,gated
Content-Length: 226
Content-Type: application/sdp

v=0
o=- 7316347 7316347 IN IP4 10.225.0.126
s=SBC call
c=IN IP4 10.225.0.126
t=0 0
m=audio 26234 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=ptime:20
a=rtpmap:101 telephone-event/8000
a=ptime:20
a=maxptime:140
a=sendrecv

[2024-11-13 18:21:22] VERBOSE[4898] res_rtp_asterisk.c: 0x7f2060013de0 -- Strict RTP learning after remote address set to: 10.225.0.126:26234
[2024-11-13 18:21:22] VERBOSE[4898] res_pjsip_logger.c: <--- Transmitting SIP request (475 bytes) to UDP:10.225.0.1:5060 --->
PRACK sip:10.225.0.1:5060;Hpt=8f32_16;CxtId=3;TRC=ffffffff-ffffffff SIP/2.0
Via: SIP/2.0/UDP 10.194.7.168:5060;rport;branch=z9hG4bKPj50500eb0-cc36-4e08-83b3-f7cc63de50ba
From: <sip:[email protected]>;tag=8f155367-5d83-4d6b-b48e-de132cfecf79
To: <sip:[email protected]>;tag=fqrt6i3g-CC-165
Call-ID: a1b6e518-c1c5-4c08-8b8e-6aacf55c9c41
CSeq: 18582 PRACK
RAck: 1 18581 INVITE
Max-Forwards: 70
User-Agent: FPBX-17.0.19.16(21.5.0)
Content-Length:  0

[2024-11-13 18:21:22] VERBOSE[1746] res_pjsip_logger.c: <--- Received SIP response (341 bytes) from UDP:10.225.0.1:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.194.7.168:5060;branch=z9hG4bKPj50500eb0-cc36-4e08-83b3-f7cc63de50ba;rport=5060
Call-ID: a1b6e518-c1c5-4c08-8b8e-6aacf55c9c41
From: <sip:[email protected]>;tag=8f155367-5d83-4d6b-b48e-de132cfecf79
To: <sip:[email protected]>;tag=fqrt6i3g-CC-165
CSeq: 18582 PRACK
Content-Length: 0


[2024-11-13 18:21:24] VERBOSE[4898] res_pjsip_logger.c: <--- Transmitting SIP request (463 bytes) to UDP:10.225.0.1:5060 --->
CANCEL sip:10.225.0.1:5060 SIP/2.0
Via: SIP/2.0/UDP 10.194.7.168:5060;rport;branch=z9hG4bKPj153e29ad-95ec-45f5-8aa3-b220cd949498
From: <sip:[email protected]>;tag=8f155367-5d83-4d6b-b48e-de132cfecf79
To: <sip:[email protected]>
Call-ID: a1b6e518-c1c5-4c08-8b8e-6aacf55c9c41
CSeq: 18581 CANCEL
Reason: Q.850;cause=127
Route: <sip:[email protected]:5060>
Max-Forwards: 70
User-Agent: FPBX-17.0.19.16(21.5.0)
Content-Length:  0


[2024-11-13 18:21:24] VERBOSE[7802][C-00000007] pbx.c: Executing [s@crm-hangup:5] GotoIf("PJSIP/752-00000008", "0?return") in new stack
[2024-11-13 18:21:24] VERBOSE[7802][C-00000007] pbx.c: Executing [s@crm-hangup:6] Set("PJSIP/752-00000008", "__CRM_HANGUP=1") in new stack
[2024-11-13 18:21:24] VERBOSE[7802][C-00000007] pbx.c: Executing [s@crm-hangup:7] AGI("PJSIP/752-00000008", "agi://127.0.0.1/sangomacrm.agi") in new stack
[2024-11-13 18:21:24] VERBOSE[1746] res_pjsip_logger.c: <--- Received SIP response (342 bytes) from UDP:10.225.0.1:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.194.7.168:5060;branch=z9hG4bKPj153e29ad-95ec-45f5-8aa3-b220cd949498;rport=5060
Call-ID: a1b6e518-c1c5-4c08-8b8e-6aacf55c9c41
From: <sip:[email protected]>;tag=8f155367-5d83-4d6b-b48e-de132cfecf79
To: <sip:[email protected]>;tag=fqrt6i3g-CC-165
CSeq: 18581 CANCEL
Content-Length: 0


[2024-11-13 18:21:24] VERBOSE[1746] res_pjsip_logger.c: <--- Received SIP response (443 bytes) from UDP:10.225.0.1:5060 --->
SIP/2.0 487 Request Terminated
Via: SIP/2.0/UDP 10.194.7.168:5060;branch=z9hG4bKPj153e29ad-95ec-45f5-8aa3-b220cd949498;rport=5060
Call-ID: a1b6e518-c1c5-4c08-8b8e-6aacf55c9c41
From: <sip:[email protected]>;tag=8f155367-5d83-4d6b-b48e-de132cfecf79
To: <sip:[email protected]>;tag=fqrt6i3g-CC-165
CSeq: 18581 INVITE
Warning: 399 10.225.0.1 "SS280000F582L227[00000] Cancel received on initial invite"
Content-Length: 0


[2024-11-13 18:21:24] VERBOSE[4898] res_pjsip_logger.c: <--- Transmitting SIP request (452 bytes) to UDP:10.225.0.1:5060 --->
ACK sip:10.225.0.1:5060 SIP/2.0
Via: SIP/2.0/UDP 10.194.7.168:5060;rport;branch=z9hG4bKPj153e29ad-95ec-45f5-8aa3-b220cd949498
From: <sip:[email protected]>;tag=8f155367-5d83-4d6b-b48e-de132cfecf79
To: <sip:[email protected]>;tag=fqrt6i3g-CC-165
Call-ID: a1b6e518-c1c5-4c08-8b8e-6aacf55c9c41
CSeq: 18581 ACK
Route: <sip:[email protected]:5060>
Max-Forwards: 70
User-Agent: FPBX-17.0.19.16(21.5.0)
Content-Length:  0

Please explain what you are trying to achieve here. I suspect you have mixed up prepend and prefix, but without knowing the intention, I can’t be sure.

I don’t know how this is possible. Have you ediitted this part of the log? I’d expect there to be a request URI that was the same as the To one.

Sorry, let me start over.

I wanted to switch over to FreePBX from a zycoo IP PBX.

I tried to copy the trunk settings from the old one but it wouldn’t register. But I found someone tried to setup using MicroSIP from the same provider had a sip proxy. So I tried to add the proxy in outbound proxy. The trunk was registered and inbound calls works but outbound did not.
For the outbound route I set it up the same as the old ip pbx. when testing I tried dialing by prepend 9 and no prepends.

Settings from the old pbx



FreePBX trunk settings


FreePBX logs
https://pastebin.freepbx.org/view/74486928

Actually I do now understand why the request URI is wrong. chan_pjsip requires proxies to be specified in the full Record-Route format, so, normally requires ;lr to be appended and often requires ;hide, so no actual Route header is created. ; needs escaping, using backslash.

To make clearer what @david55 said, try setting Outbound Proxy to
sip:10.225.0.1\;lr\;hide
exactly as you see it above.

Thank you! outbound calls are working now but I have another problem. There are some inbound calls that are not working. When I answered the call, it hangs up. What I have noticed is calls that have numbers hangs up when answered and calls that don’t have are fine. This also happened in the previous pbx. I thought changing to FreePBX would fix it because using MicroSIP, it was fine.

hangs up
From: "+6011XXXXXXXXX"sip:[email protected];tag=565pjftt-CC-165

can be answered
From: sip:[email protected];cpc=ordinary;tag=tigifz5u-CC-165

FreePBX logs (not working)
freepbx logs - FreePBX Pastebin

SIP Logs from zycoo ippbx through Homer (working)
logs - FreePBX Pastebin

From: "+6011XXXXXXXXX"<sip:[email protected]>;tag=565pjftt-CC-165

From: <sip:[email protected];cpc=ordinary>;tag=tigifz5u-CC-165

Neither of these have numbers. The first one has a name. I really wouldn’t expect the presence or absence of a name to affect how FreePBX handles the call. The name is only use to pass through to the callee.

A more significant difference is the URI parameter, in the second one, but I think Asterisk will ignore this.

Asterisk has answered the call correctly. It is the provider that has immediately ended it. The only legitimate reason I know for that is when the UAS sends an unacceptable SDP offer, and that doesn’t seem to be the case here.