Linksys SPA3000 PSTN Gateway w/ FreePBX 13 Inbound Not Ringing

Looks like you are having the same trouble I was having making heads or tails out of what each field is really asking. While I frustrated the, very helpful, gentleman on IRC, I think the fault likes in the docs (or lack thereof). Also, you seem to be using a different version of the sipura 3000 firmware than I am, but I don’t think that is an issue.

Anyway, on the line 1 page, proxy should be 192.168.1.47:5160. Use outbound proxy and use ob proxy in dialog should be no. I don’t have SIP transport, but I think mine does use UDP.

On the PSTN line page, once again, proxy needs to be 192.168.1.47:5160. Also turn off use outbond proxy proxy etc.

On your sip settings in trunk, host has to be dynamic to register. I was told not to have it register since it was less secure than hardcoding which ip was allowed to call, but I did leave mine registering as it also allowed me to see when things were properly connected.

Also, make sure port in the extension advanced menu matches what you set for port on your line 1 page.

After you make those changes, you should see on the main sipura 3000 page that the PSTN line has registered. Once that is the case, things should start working.

I’m using PJSIP for this extension. This doesn’t sound right to me, since 5160 is a port for chan_sip? Also, the original guide suggests that PJSIP was used for the extension without problems. Either way, the idea behind this PSTN trunk is to be able to answer landline calls on any of my SIP extensions, and this ATA will be rarely used apart from that. I didn’t think that the Line 1 and PSTN Line on the ATA are linked in any way?. Either way the extension I set on my ATA is 100, and the extension I have setup on my inbound route is 401 (different building), but eventually I’ll setup a ring group so I can answer it on a handful of different extensions if needed (obviously max calls = 1, it’s still PSTN). Is chan_sip a requirement on my extensions…??

Okay, done, Outbound proxy was already disabled, is there anything else I need to change? Not sure what you mean by “etc”. I currently have “Use OB Proxy in Dialog” enabled, not sure if I need to change that.

Okay, I changed “192.168.1.25” to “dynamic”. On the info page under PSTN Line Status, Registration State = Failed. Not sure if this is OK or not.

Again a bit confused here with the whole chan_sip vs pjsip thing for my extensions. My extensions are working perfectly fine otherwise and I would like to avoid having to change them all if possible… I think I also had issues with chan_sip for extensions which is why I kept with pj_sip.

At the moment nothing happens on my asterisk console when I try to call.

No, but it is the way I’m setup and it works. :slight_smile: [quote=“stephendt, post:22, topic:37496”]
I currently have “Use OB Proxy in Dialog” enabled, not sure if I need to change that.
[/quote]

Mine is set to no, but it seems to work either way of use outbound proxy is off.

It should not be failed. If you are seeing nothing in the console, what about the full log? I think you said the firewall was disabled, if not, disable it to make sure nothing is being blocked.

The port mentioned in the advanced section is the one asterisk will use to talk to the sipura 3000. It needs to match what port number is set on the line 1 page.

Success! I got it working. Finally! You were pretty close, but if you were following my setup I was opting to use port 5061 rather than 5160. That was tripping me up and was breaking things. The moment I switched over to 5061, it worked. Thank you.

Also, chan_sip for Line 1 was unnecessary as I had thought.

There was another thing I had to change - PSTN calls weren’t ringing until around 16 seconds in. Changing “PSTN Answer Delay” to 0 under PSTN Line fixed that.

The last thing I can’t seem to get working is caller ID. Anyone have any ideas where to look? I tried changing “PSTN CID for VOIP CID” to “Yes” and putting a * under “PSTN Caller ID pattern”, but that didn’t seem to have an effect.

Glad you got it working.

Caller id works (most of the time) for me. The trick was to tell FreePBX to wait a bit before answering the phone. It has to get two rings in order to be able to read the callerid info.

Gotcha. I’ll try that soon.

Edit: Worked a treat! Consider this thread solved.

I think I’ve got the same problem with an SPA3102. The extension / FXS port is registering fine as a pjsip extension, however, if I try to configure the trunk as pjsip, it works and I can receive incoming calls and make outgoing calls on the trunk, but the extension can no longer register, and freepbx returns 404 not found when the extension tries to register. If I try changing the trunk to chansip, the extension stays registered, but I cannot receive incoming calls on it. Freepbx returns 401 Unauthorised on an incoming call. The SPA3102 responds to the challenge with the username (and I assume) password I have configured on the trunk, but Freepbx replies with 401 Unauthorised again and the incoming call fails. Here’s the asterisk log of the incoming call:

[2017-07-24 07:59:02] NOTICE[24256] res_pjsip/pjsip_distributor.c: Request from ‘“PSTN” sip:[email protected]’ failed for ‘192.168.100.113:5160’ (callid: [email protected]) - No matching endpoint found
[2017-07-24 07:59:02] SECURITY[6664] res_security_log.c: SecurityEvent=“InvalidAccountID”,EventTV=“2017-07-24T07:59:02.002+1000”,Severity=“Error”,Service=“PJSIP”,EventVersion=“1”,AccountID=“1-pstn”,SessionID="[email protected]",LocalAddress=“IPV4/UDP/192.168.100.100/5060”,RemoteAddress=“IPV4/UDP/192.168.100.113/5160”
[2017-07-24 07:59:02] SECURITY[6664] res_security_log.c: SecurityEvent=“ChallengeSent”,EventTV=“2017-07-24T07:59:02.003+1000”,Severity=“Informational”,Service=“PJSIP”,EventVersion=“1”,AccountID="",SessionID="[email protected]",LocalAddress=“IPV4/UDP/192.168.100.100/5060”,RemoteAddress=“IPV4/UDP/192.168.100.113/5160”,Challenge=""
[2017-07-24 07:59:02] NOTICE[24256] res_pjsip/pjsip_distributor.c: Request from ‘“PSTN” sip:[email protected]’ failed for ‘192.168.100.113:5160’ (callid: [email protected]) - No matching endpoint found
[2017-07-24 07:59:02] SECURITY[6664] res_security_log.c: SecurityEvent=“InvalidAccountID”,EventTV=“2017-07-24T07:59:02.013+1000”,Severity=“Error”,Service=“PJSIP”,EventVersion=“1”,AccountID=“1-pstn”,SessionID="[email protected]",LocalAddress=“IPV4/UDP/192.168.100.100/5060”,RemoteAddress=“IPV4/UDP/192.168.100.113/5160”
[2017-07-24 07:59:02] SECURITY[6664] res_security_log.c: SecurityEvent=“ChallengeResponseFailed”,EventTV=“2017-07-24T07:59:02.013+1000”,Severity=“Error”,Service=“PJSIP”,EventVersion=“1”,AccountID="",SessionID="[email protected]",LocalAddress=“IPV4/UDP/192.168.100.100/5060”,RemoteAddress=“IPV4/UDP/192.168.100.113/5160”,Challenge=“1500847142/51218d58c6c5f7efebe1ecc36860feb4”,Response=“b891ec576f2e338e154da8ca85fdaf5b”,ExpectedResponse=""
[2017-07-24 07:59:02] NOTICE[24256] res_pjsip/pjsip_distributor.c: Request from ‘“PSTN” sip:[email protected]’ failed for ‘192.168.100.113:5160’ (callid: [email protected]) - No matching endpoint found
[2017-07-24 07:59:02] SECURITY[6664] res_security_log.c: SecurityEvent=“InvalidAccountID”,EventTV=“2017-07-24T07:59:02.023+1000”,Severity=“Error”,Service=“PJSIP”,EventVersion=“1”,AccountID=“1-pstn”,SessionID="[email protected]",LocalAddress=“IPV4/UDP/192.168.100.100/5060”,RemoteAddress=“IPV4/UDP/192.168.100.113/5160”
[2017-07-24 07:59:02] SECURITY[6664] res_security_log.c: SecurityEvent=“ChallengeResponseFailed”,EventTV=“2017-07-24T07:59:02.023+1000”,Severity=“Error”,Service=“PJSIP”,EventVersion=“1”,AccountID="",SessionID="[email protected]",LocalAddress=“IPV4/UDP/192.168.100.100/5060”,RemoteAddress=“IPV4/UDP/192.168.100.113/5160”,Challenge=“1500847142/51218d58c6c5f7efebe1ecc36860feb4”,Response=“0c236ed952556fbcebf7ce410749eff5”,ExpectedResponse=""
^C

And the trace:

Line 1 (FXS) on the SPA3102 is set for port 5060 and PSTN Line is set for port 5061. Trunk config (chansip) is as follows:

user=1-pstn
secret=*******
canreinvite=no
context=from-pstn
host=192.168.100.113
nat=no
port=5061
type=friend
qualify=yes

Any ideas??

Some additional info… if I set the PSTN Line on the SPA3102 to register, similar behaviour occurs. The SPA3102 sends the registration request, FreePBX challenges with 401 Unauthorised, SPA3102 replies with username / password, but FreePBX rejects it with another 401 Unauthorised. It is as though FreePBX doesn’t recongnise the username / password. Have double checked and triple checked username and password are correct between SPA3102 PSTN line and the FreePBX trunk.

Sorry about the slow reply, I’ve been out of town.

Anyway, the one thing I see that might help is that if you are going to register, you need to set host=dynamic.

Hi Karl,

Thanks for responding.

I assume you mean to change the host= stanza in the Freepbx trunk config from:
host=192.168.100.113
to
host=dynamic
I tried this but no luck. Same symptoms. Gateway trunk will not register (401 unauthorised) and incoming calls will not terminate (401 unauthorised). Outbound calls via gateway are fine. Extension registers no problem on port 5060 as a pjsip extension.

Heres the PSTN Line SPA3102 config:


You should not need to register this particular gateway. It works OK without registration. Be sure to disable registration and also disable pstn ring thru line 1

I’ve tried without registering (was just trying it to prove that there is something wrong with the id / password acceptance), and now removed the ring thru (was keeping that in case of failure). Inbound call attempts still fail with 401 unauthorised from Freepbx.Also, I had this gateway running fine with this config (no registration) on an old Trixbox. Pretty sure something is not right at the Freepbx end, but I just can’t work out what. Freepbx trunk name matches the gateway name, and checked user name and password.


Are you using the insecure directive on the trunk?

Yes.host currently set to dynamic as suggested earlier. Was set to the ip address of the gateway.

username=pstn540
secret=*************
canreinvite=no
context=from-pstn
host=dynamic
nat=no
port=5061
type=friend
qualify=yes
insecure=very
incominglimit=1

Try insecure=port,invite

“very” has been deprecated a long time ago

I tried insecure=port,invite, but no dice. Same behaviour on incoming calls.

One thing I did notice in the trace though. The SPA 3102 is using source port 5061 (as per the config) but send to destination port 5060. I wonder if this is what confuses asterisk, because that’s the port for the extension.

If your asterisk is running on port 5060 then it is OK that the SPA is sending to that port

OK found the problem. It was the destination port that was the problem as I suspected. In the error messages I posted earlier, you can see pjsip trying to answer the trunk call, because pjsip is on port 5060. The chansip trunk was on 5061, so the destination port needs to be 5061.

The solution was in a post from Karl earlier:

The trick to using chan_sip (and something I did not find documented anywhere) is to specify the proxy using the format:

ip:port.

I thought Karl was referring to the FreePBX trunk setting host= stanza. It was the proxy in the SPA3102. Here’s what works for clarity. This ensures the SPA3102 sends the invite to destination port 5061, which matches the port you have the asterisk trunk configured on.

So it is imperative you have the right sip stack listening on the right port from a common ip address.

Now the only thing not working is caller id. I’ll go back over the posts here to try and resolve that now.

UPDATE: And yes, setting a PSTN answer delay on the gateway fixed CLI:

the easiest way is to prevent problems with fail2ban is to whitelist the SPA’s IP address.

Sorry to reopen an old thread but I ran into this issue with pjsip and the SPA3000, and found this thread but no answer when keeping the caller ID. I didn’t give up and have an answer.

Adding the below to the pjsip.conf replacing the four fields (shown as angled bracket) as appropriate should solve the issue.

[<spa3000 identifier name>]
type = identify
endpoint = <spa3000 endpoint name>
match = <spa3000 fqdn>:<spa3000 port number>

I tend to keep the endpoint and identifier name the same, the port would be 5061 and the fqdn could also be a static IP.

Hope that helps anybody following me.