Issues configuring HT841 as a local trunk

Fresh install of Freepbx 16.
Grandstream HT841
jpsip only, chansip disabled.

Both on the same lan.

I’ve used Dahdi for years with an old PCI card and it worked flawlessly.

I reinstalled freepbx and decided to move into a VM on a local server.

To replace the Dahdi PCI card I opted for a Grandstream HT841.

4 x analogue phone lines coming in from my telco.

I have tried mulitple configurations, I can get incoming :

telco–>HT841–>freepbx

to work no problem

However after numerous configurtion attemps, for the life of me I cannot get

freepbx–>ht841–>telco
(outgoing calls via the grandstream)

to work

thankfully I have a voip line as well, so I’ve been able to “fall back” on that for outgoing calls.

Currently I have Authentication set to None as well as registration set to none.

As I have numerous local sip extensions, turning pjsip set logger on damn near crashes the log viewer, as the phones are constantly generation log entries.

in my event log I can see what looks like a SIP/2.0 403 Forbidden back from the grandstream

However, on the grandstream itself, under the FXO profile (that I am using) I have “outgoing calls without registration” checked off.

Event log for an outoing call attemps

167617 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] app_stack.c: PJSIP/telco_Line_1-00000065 Internal Gosub(func-apply-sipheaders,s,1(1)) start
167618 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [s@func-apply-sipheaders:1] ExecIf(“PJSIP/telco_Line_1-00000065”, “0?Set(CHANNEL(hangup_handler_push)=crm-hangup,s,1)”) in new stack
167619 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [s@func-apply-sipheaders:2] NoOp(“PJSIP/telco_Line_1-00000065”, “Applying SIP Headers to channel PJSIP/telco_Line_1-00000065”) in new stack
167620 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [s@func-apply-sipheaders:3] Set(“PJSIP/telco_Line_1-00000065”, “localchan=telco_Line_1-00000065”) in new stack
167621 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [s@func-apply-sipheaders:4] Set(“PJSIP/telco_Line_1-00000065”, “DialMCEXT=telco_Line_1”) in new stack
167622 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [s@func-apply-sipheaders:5] Set(“PJSIP/telco_Line_1-00000065”, “CHANNEL(hangup_handler_push)=app-missedcall-hangup,telco_Line_1,1”) in new stack
167623 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [s@func-apply-sipheaders:6] Set(“PJSIP/telco_Line_1-00000065”, “TECH=PJSIP”) in new stack
167624 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [s@func-apply-sipheaders:7] Set(“PJSIP/telco_Line_1-00000065”, “SIPHEADERKEYS=Alert-Info”) in new stack
167625 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [s@func-apply-sipheaders:8] While(“PJSIP/telco_Line_1-00000065”, “1”) in new stack
167626 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [s@func-apply-sipheaders:9] Set(“PJSIP/telco_Line_1-00000065”, “sipheader=unset”) in new stack
167627 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [s@func-apply-sipheaders:10] ExecIf(“PJSIP/telco_Line_1-00000065”, “1?Set(PJSIP_HEADER(remove,Alert-Info)=)”) in new stack
167628 [2025-09-21 17:14:13] ERROR[151468] res_pjsip_header_funcs.c: No headers had been previously added to this session.
167629 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [s@func-apply-sipheaders:11] ExecIf(“PJSIP/telco_Line_1-00000065”, “0?Set(sipheader=http://127.0.0.1;info=unset)”) in new stack
167630 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [s@func-apply-sipheaders:12] ExecIf(“PJSIP/telco_Line_1-00000065”, “0?Set(sipheader=http://127.0.0.1unset)”) in new stack
167631 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [s@func-apply-sipheaders:13] ExecIf(“PJSIP/telco_Line_1-00000065”, “0?Set(PJSIP_HEADER(add,Alert-Info)=unset)”) in new stack
167632 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [s@func-apply-sipheaders:14] EndWhile(“PJSIP/telco_Line_1-00000065”, “”) in new stack
167633 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [s@func-apply-sipheaders:8] While(“PJSIP/telco_Line_1-00000065”, “0”) in new stack
167634 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [s@func-apply-sipheaders:15] Return(“PJSIP/telco_Line_1-00000065”, “”) in new stack
167635 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] app_stack.c: Spawn extension (func-apply-sipheaders, s, 15) exited non-zero on ‘PJSIP/telco_Line_1-00000065’
167636 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] app_stack.c: PJSIP/telco_Line_1-00000065 Internal Gosub(func-apply-sipheaders,s,1(1)) complete GOSUB_RETVAL=
167637 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] app_dial.c: Called PJSIP/number_i_am_trying_to_dial_out_to@telco_Line_1
167638 [2025-09-21 17:14:13] VERBOSE[122732] res_pjsip_logger.c: <— Transmitting SIP request (1041 bytes) to UDP:ip_of_grandstream:5060 —>
167639 INVITE sip:number_i_am_trying_to_dial_out_to@ip_of_grandstream:5060 SIP/2.0
167640 Via: SIP/2.0/UDP ip_of_freepbx:5060;rport;branch=z9hG4bKPjac289e74-10cf-434e-b775-fe1031e6f726
167641 From: “companyname” sip:phone_number_of_company@ip_of_freepbx;tag=3ad08eb2-c0b3-4772-b770-60c8ab4a2f6a
167642 To: sip:number_i_am_trying_to_dial_out_to@ip_of_grandstream
167643 Contact: sip:asterisk@ip_of_freepbx:5060
167644 Call-ID: 418a9346-97db-4cdc-b2cd-ae764abc7ca6
167645 CSeq: 20124 INVITE
167646 Allow: OPTIONS, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, MESSAGE, REFER
167647 Supported: 100rel, timer, replaces, norefersub, histinfo
167648 Session-Expires: 1800
167649 Min-SE: 90
167650 Max-Forwards: 70
167651 User-Agent: FPBX-16.0.41(18.16.0)
167652 Content-Type: application/sdp
167653 Content-Length: 341
167654
167655 v=0
167656 o=- 368562395 368562395 IN IP4 ip_of_freepbx
167657 s=Asterisk
167658 c=IN IP4 ip_of_freepbx
167659 t=0 0
167660 m=audio 18326 RTP/AVP 0 8 3 111 9 101
167661 a=rtpmap:0 PCMU/8000
167662 a=rtpmap:8 PCMA/8000
167663 a=rtpmap:3 GSM/8000
167664 a=rtpmap:111 G726-32/8000
167665 a=rtpmap:9 G722/8000
167666 a=rtpmap:101 telephone-event/8000
167667 a=fmtp:101 0-16
167668 a=ptime:20
167669 a=maxptime:150
167670 a=sendrecv
167671
167672 [2025-09-21 17:14:13] VERBOSE[2454] res_pjsip_logger.c: <— Received SIP response (504 bytes) from UDP:ip_of_grandstream:5060 —>
167673 SIP/2.0 100 Trying
167674 Via: SIP/2.0/UDP ip_of_freepbx:5060;rport=5060;branch=z9hG4bKPjac289e74-10cf-434e-b775-fe1031e6f726
167675 From: “companyname” sip:phone_number_of_company@ip_of_freepbx;tag=3ad08eb2-c0b3-4772-b770-60c8ab4a2f6a
167676 To: sip:number_i_am_trying_to_dial_out_to@ip_of_grandstream
167677 Call-ID: 418a9346-97db-4cdc-b2cd-ae764abc7ca6
167678 CSeq: 20124 INVITE
167679 User-Agent: Grandstream HT841 1.0.9.9
167680 Supported: replaces, path, timer, eventlist
167681 Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE
167682 Content-Length: 0
167683
167684
167685 [2025-09-21 17:14:13] VERBOSE[2454] res_pjsip_logger.c: <— Received SIP response (521 bytes) from UDP:ip_of_grandstream:5060 —>
167686 SIP/2.0 403 Forbidden
167687 Via: SIP/2.0/UDP ip_of_freepbx:5060;rport=5060;branch=z9hG4bKPjac289e74-10cf-434e-b775-fe1031e6f726
167688 From: “companyname” sip:phone_number_of_company@ip_of_freepbx;tag=3ad08eb2-c0b3-4772-b770-60c8ab4a2f6a
167689 To: sip:number_i_am_trying_to_dial_out_to@ip_of_grandstream;tag=573418735
167690 Call-ID: 418a9346-97db-4cdc-b2cd-ae764abc7ca6
167691 CSeq: 20124 INVITE
167692 User-Agent: Grandstream HT841 1.0.9.9
167693 Supported: replaces, path, timer, eventlist
167694 Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE
167695 Content-Length: 0
167696
167697
167698 [2025-09-21 17:14:13] VERBOSE[59751] res_pjsip_logger.c: <— Transmitting SIP request (425 bytes) to UDP:ip_of_grandstream:5060 —>
167699 ACK sip:number_i_am_trying_to_dial_out_to@ip_of_grandstream:5060 SIP/2.0
167700 Via: SIP/2.0/UDP ip_of_freepbx:5060;rport;branch=z9hG4bKPjac289e74-10cf-434e-b775-fe1031e6f726
167701 From: “companyname” sip:phone_number_of_company@ip_of_freepbx;tag=3ad08eb2-c0b3-4772-b770-60c8ab4a2f6a
167702 To: sip:number_i_am_trying_to_dial_out_to@ip_of_grandstream;tag=573418735
167703 Call-ID: 418a9346-97db-4cdc-b2cd-ae764abc7ca6
167704 CSeq: 20124 ACK
167705 Max-Forwards: 70
167706 User-Agent: FPBX-16.0.41(18.16.0)
167707 Content-Length: 0
167708
167709
167710 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] app_stack.c: PJSIP/telco_Line_1-00000065 Internal Gosub(app-missedcall-hangup,telco_Line_1,1) start
167711 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [telco_Line_1@app-missedcall-hangup:1] NoOp(“PJSIP/telco_Line_1-00000065”, “Dialed: telco_Line_1”) in new stack
167712 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [telco_Line_1@app-missedcall-hangup:2] NoOp(“PJSIP/telco_Line_1-00000065”, “Caller: 401”) in new stack
167713 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [telco_Line_1@app-missedcall-hangup:3] GotoIf(“PJSIP/telco_Line_1-00000065”, “0?exit”) in new stack
167714 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [telco_Line_1@app-missedcall-hangup:4] Set(“PJSIP/telco_Line_1-00000065”, “EXTENNUM=telco_Line_1”) in new stack
167715 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [telco_Line_1@app-missedcall-hangup:5] Set(“PJSIP/telco_Line_1-00000065”, “FEXTENNUM=telco_Line_1”) in new stack
167716 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [telco_Line_1@app-missedcall-hangup:6] GotoIf(“PJSIP/telco_Line_1-00000065”, “0?exit”) in new stack
167717 [2025-09-21 17:14:13] VERBOSE[166784][C-0000002c] pbx.c: Executing [telco_Line_1@app-missedcall-hangup:7] AGI(“PJSIP/telco_Line_1-00000065”, “agi://127.0.0.1/missedcallnotify.php,telco_Line_1,telco_Line_1,0,PJSIP/telco_Line_1-00000065,”) in new stack

Possibly, the call is being sent to the wrong profile.

Confirm that SIP Server Port for the trunk (apparently 5060) matches the value of Local SIP Port for the FXO profile for the FXO port you are trying to call out on.

Please post screenshots for the other tabs in the HT841.
Or check: Dial Plan, Stage Method, Hunting group, Local SIP Port.

Staging method was set to 2, I switched it to 1

image

I’m very puzzled. Stage method 2 would indeed cause a 403 error, but you switched it to 1 and nothing changed? Possibly you are now getting a different error, in which case post a new log.
So we can see the format, please call a number you don’t have to redact, e.g., a local McDonald’s.

The Dial Plan looks fine (assuming that it’s for the FXO, not the FXS).

The HT has various security settings that will reject calls if the remote IP address, username, etc. aren’t as expected. They all default to off, but you may have accidentally set one.

If you can’t easily find the cause of the 403, you might set up syslog with EXTRA DEBUG level and hope the the reason for rejection is logged in an understandable format.

Another option (which may not help but might avoid a problem we aren’t seeing) is to set up the HT in the ‘usual’ way, where it registers to the PBX. For the trunk settings try:
Trunk Name: (same as SIP User ID on HT)
Authentication: Both
Registration: Receive
Secret: (same as SIP Authenticate Password on HT)
Match Inbound Authentication: Auth Username
Rewrite Contact: Yes

Stewart, thank you so much it is now working!

Switching stage method to 1 appears to have solved it.

For “the next guy” coming accross this post.

in freepbx (16 in my case)
I made 4 PJSIP trunks in freepbx, one for each line.

Authentication none
Registration none
sip server is the local ip of the grandstream gateway
Trunk one is port 5060
Trunk 2 is port 5062
Trunk 3 is port 5064
Trunk 4 is port 5066

in the grandstream
FXO profile 1 → channel Dialing ->Stage method 1 (this was my issue)
FXO profile 1 → sip settings-> registration off
FXO profile 1 → sip settings-> local sip port 5060

FXO ports
All the top settings blank, set to FXO profile 1

All the bottom settings set to

public phone number @ ip of freepbx : 5060

I struggled with the HT841 too when trying to register it as a local trunk. The main issue was matching the SIP settings—especially authentication and context—in both FreePBX and the ATA. Once I aligned the dial patterns and set the trunk to use IP-based authentication, it finally worked. Debugging with Asterisk logs was the only way I spotted the mismatch.

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