FreePBX and Grandstream HT813

Hey,

I work in IT and wanted to start a home project, where I set up a phone system and replace my analogue telephones with IP phones. I have so far, managed to achieve this to an extent, but having some trouble getting the FXS port on the Grandstream HT813 to register a SIP extension on my install of FreePBX.

I have one pjsip trunk which routes calls from VOIP to the FXO port on the Grandstream HT813. If I disable this trunk, the FXS port will successfully register and I can then call the extension from an IP phone. If I then re-enable the trunk, the registration of the SIP extension on FXS breaks and the FreePBX log fills up with “WARNING[2615] res_pjsip_registrar.c: AOR ‘’ not found for endpoint ‘Grandstream’ (10.0.1.245:5060)”.

I have tried creating a second pjsip trunk with sip server port 5060, the current trunk is using port 5062, but regardless of how many settings I change, the registration repeatedly uses the first trunk in the list. I even tried enabling “Continue if Busy”, but it will continiously use the first trunk. If I populate the AOR value on this trunk with the extension 5836, registration works but all outgoing calls then route to extension 5836?

I am very new to all of this so I probably have missed something. I would greatly appreciate any advise that could be given. The FXO port is connected to the PSTN line.

Cheers,
Richie

How are you matching the trunK?

Hi David,

Thank you for getting back to me. I’m really new to this so I’m not exactly sure, I have one trunk and one outbound route. The outbound route is then linked to the trunk.







Cheers,
Richie

image

You are matching the trunk on IP address, so the extensions also matches the trunk. You probably need everything set to dynamic (and receive registration), unless you can set a specific port number on the trunk, at the HT813 end.

Using dynamic may mean you have to enable Remote-Party-ID or P-Asserted-Identity, for inbound caller ID.

Is there any way of stopping this behaviour? This is exactly what is happening. I tried creating a virtual IP (high availability) on my firewall that routes to the IP of the Grandstream box and I set this virtual IP at the SIP server on the trunk and the FXS port registered successfully from the real IP of the Grandstream box. This worked because there were no routes defined with that IP address. This doesn’t work in theory though as FreePBX fails to route using the virtual IP.

I can’t seem to find any way of getting around this problem. The FXS port to my knowledge just simulates an IP phone and does not require a route, it just uses the SIP server, extension and extension secret. I don’t get why FreePBX is trying to use routes for this. I’m starting to think that I won’t be able to use the FXS port on this box due to the box only having 1 IP address.

From the point of view of SIP and Asterisk, there is no difference between a “trunk” and an “extension”. (This isn’t about what FreePBX calls routes.)

The ways round it are to treat the “trunk” the same as the “extension” the same for matching, i.e. as an endpoint with a dynamic address, matched by the From user name, or to change the priority with which chan_pjsip matches user versus IP (endpoint_identify_order). I don’t know whether the latter can be done without breaking FreePBX in other ways.

I had a similar problem with the HT813. I found that the FXO and FXS sides can’t both use PJSIP. My solution was to set one or the other to Chan_SIP ( or “old” SIP). This might not be the right way to do things, and of course Chan_SIP is deprecated so someday I will need a better solution, but this worked as a quick fix.

PS: In the end, I found that an imitation SPA3102 from eBay worked better than the Grandstream. It had the same one-PJSIP-at-a-time problem, but worked better in other ways.

1 Like

I’m pretty sure if both sides were dynamic hosts, it would have worked.

1 Like

As @david55 said, there is no problem running both ports of an FXS/FXO device on pjsip.

For the benefit of others searching for this problem, these settings should apply to Grandstream HT813, HT503 (old), Cisco/Linksys SPA3102 (old), SPA3000 (really old), Obihai OBi212 and OBi110 (old).

Set up the FXS as a normal pjsip extension.

For the FXO side, set up a pjsip trunk:
Trunk Name: MYFXO (for example)
Outbound CallerID: 01234567890 (doesn’t really matter, but use the number of the PSTN line because that is what the carrier will send).
CID Options: Force Trunk CID (because that’s what will happen)
Maximum Channels: 1 (only needed if you will fail over to another trunk when this one is busy)
Secret: (must match the SIP password on the FXO device)
Authentication: Both
Registration: Receive
Match Inbound Authentication: Auth Username (needed if your device will send caller ID in From header)
Rewrite Contact: Yes (needed if device is behind NAT and not on same LAN as PBX)

The device FXO port must be set to register, with username matching the Trunk Name and password matching the trunk Secret.

If you still have trouble, paste the Asterisk log for a failing call or registration, with pjsip logger turned on.

Thank you, David, VOIPDummy and Stewart. This issue was annoying me too much as I spent days trying to resolve this and wasn’t really getting anywhere, so I ended up buying a Grandstream HT-812 to deal with the FXS side. I will of course try what you have mentioned. The problem that I was having was that whenever I had the “CALL_OUT” trunk, which needs the IP address of the HT813, that trunk would be automatically used for the SIP registration on the FXS port and would fail.

I think we are saying that statement is not true.

When both trunk and extension calls come from the same host, as in the case of a gateway with both FXO and FXS ports, then you probably want to modify the pjsip Endpoint Identifier Order in Asterisk SIP settings such that username comes before IP.

In my experience, that isn’t required when Registration for the trunk is set to Receive. It’s no different from multiple extensions from the same host, which occurs whenever there are several remote extensions at the same location, or multiple extensions on the same IP phone. In any case, with the Linksys or Obihai devices, which can only use the From field for caller ID, you need to set the trunk to identify by auth ID rather than username.

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