Set up PJSIP with AnveoDirect?

I have a DID with Anveo direct, and I want to have inbound calling only with my Asterisk server. I have confirmed everything is working using sip2sip (I call using Sip2Sip registered on Zoiper on my cell phone; and Sip2Sip registered on Asterisk with pjsip.conf). Now I have a DID with AnveoDirect, and am of the understanding that I do not register with Anveo and pjsip.conf. Here’s what I have done so far:

My Asterisk server has an A name, and can be found at my.domain.com.

In Anveo, Inbound Service > Configure Destination Trunks > Add a New SIP Trunk > 15551235555@my.domain.com (obviously 15551235555 being my DID)
Inbound Service > Configure DIDs > edit > Call Options > And then I choose my destintion SIP trunk that I created (and I also checked off G.711u for codecs)

Note: I have also tried $[E164]$@my.domain.com and it also doesn’t work.

In Asterisk pjsip.conf is where I get lost and feel like I’m guessing. Here’s what I have in pjsip.conf (based off of this post):

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060

[siptrink-aor]
type=aor
contact=sip:my.domain.com

[siptrunk]
type=endpoint
transport=transport-udp
context=from-siptrunk
disallow=all
allow=ulaw
aors=siptrunk-aor
send_diversion=yes
send_pai=yes
send_rpid=yes
trust_id_inbound=yes
direct_media=no
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes

[siptrunk-identify]
type=identify
match=my.domain.com
endpoint=siptrunk

I see that the AnveoDirect faq also suggests sbc.anveo.com but that’s for sip.conf. I tried changing contact and match to sbc.anveo.com and mixing and matching different combinations, but still can’t get it to work. When I call my DID, I get a busy signal.

Also, I set up iptables to secure my asterisk server (because it’s on GCP compute) using this tutorial. For the tutorial, I changed YOUR_HOSTNAME.no-ip.com to my.domain.com (obviously my.domain.com being my actual domain).

It’s probably something really simple, but I’m very new to Asterisk and not understanding how to receive calls.

Edit more information. I realize now that I had gotten rid of the siptrunk-registration section in my old pjsip.conf:

[siptrunk-registration]
type=registration
transport=transport-udp
outbound_auth=siptrunk-auth
server_uri=sip:sip2sip.info
client_uri=sip:mysipusername@sip2sip.info
contact_user=inbound-calls
retry_interval=60

I got rid of it because I don’t need to register the AnveoDirect DID? But the problem now is that it had contact_user=inbound-calls which is then used in extensions.conf:

[from-siptrunk]
exten => inbound-calls,1,Verbose(1,Playing some music.)
same => n,Answer
same => n,MusicOnHold(ulawstream)
same => n,Hangup()

So I don’t really know where to go from here.

my.domain.com should be Anveo’s domain, not yours.

Both of them (contact= and match=)? I already tried that and I still get a busy signal and nothing shows in the Asterisk CLI. And by “Anveo’s domain,” you mean sbc.anveo.com?

Also, I edited my post to add additional information.

It depends on which addresses they use for inbound and outbound signalling. match should be from where calls will arrive. contact should, I believe, be to where calls should be sent.

I really don’t understand what this means. What do I change in pjsip.conf and the trunk details in Anveo to make this work? My asterisk server is at my.domain.com and pjsip.conf is listening on port 5060. I only want to receive calls to my Asterisk server from landlines, cell phones, etc and then place them on moh.

I’m not familiar with Anveo’s service, so I don’t know what is needed. However I can definitely tell you that putting your own address in those two places is wrong.

This says how to set match, for Anveo:

Under [siptrink-aor] I have:

contact=sip:sbc.anveo.com

Under [siptrunk-identify] I have:

type=identify
match=sbc.anveo.com
match=67.212.84.21
match=176.9.39.206
match=169.48.232.158
match=72.9.149.25
endpoint=siptrunk

I opened asterisk cli and turned on the logger and set verbose to 9. When I call my DID phone number, nothing happens in the cli and I get a busy signal on the phone that I’m calling from.

I also did sudo service netfilter-persistent stop to turn off iptables in case it was something in that.

Do you have a local phone. If not you need one, as the first thing to do is get that working. Then use it to make an outgoing call through Anveo. If either step fails, use “pjsip set logger on” to find out what is being sent and received and exactly where things break.

Once you have that working, see of Anveo can provide you with similar logs, for an incoming call. If not, or they show that the call was being correctly routed to you, use sngrep to see if they are arriving on your machine and confirm that they are on the right port number. If that is the case, but they are not showing with pjsip set logger on, you have a firewall problem.

If they appear with pjsip set logger on, look at how they fail.

I think termination costs more money to get it set up with Anveo. I am not planning on ever to make outgoing calls with Anveo. I only want a DID to receive calls to Anveo. So I don’t have a local phone. Is there anything I can do to log incoming calls from a pstn line, cell or another VoIP provider (I have FreePhoneLine as my home phone)?

The point about getting the outbound calls working was that you will get some protocol logged, so you are more likely to be able to debug things that completely break the Anveo account.

Inbound only, either the call is not being sent to your network, in which case you can only debug it at the Anveo end, or it is getting there, but is being blocked by a firewall, nor properly port forwarded, being sent to the wrong port, or Asterisk isn’t actually listening on the port that you think it is. You have to get logs from your network devices working back until you do find something arriving.

Using a local SIP phone also allows you to confirm that you haven’t done something silly that has resulted in chan_pjsip not having been started, or port 5060 having been blocked. You basically get something to work, then expand outwards from there.

I’m finally getting somewhere. I don’t have outbound calling set up, but I went to my GCP instance running Asterisk and opened port 5060. I didn’t think I needed to since it worked fine with sip2sip not having the port opened with GCP.

I checked the asterisk CLI, and this is what showed when I called my DID:

res_pjsip_session.c:3975 new_invite:  siptrunk: Call (UDP:169.48.232.158:5060) to extension '15551235555' rejected because extension not found in context 'from-siptrunk'.
<--- Transmitting SIP response (447 bytes) to UDP:169.48.232.158:5060 --->
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 169.48.232.158:5060;rport=5060;received=169.48.232.158;branch=z9hG4bK5a0f6a079fa15290c7a5720af273776b
Call-ID: 1QMAB9UBT91LD8F0UKL7VFCIUS@81.201.85.47-b2b_1
From: "My Home Phoneline" <sip:15553215555@169.48.232.158>;tag=5e4d3a6ea638066c8bff3783e249fc56
To: <sip:15551235555@my.domain.com>;tag=6a5999a5-6e9e-4425-bbfb-1596c77819bd
CSeq: 200 INVITE
Server: Asterisk PBX 16.22.0
Content-Length:  0


<--- Received SIP request (466 bytes) from UDP:169.48.232.158:5060 --->
ACK sip:15551235555@my.domain.com:5060 SIP/2.0
Via: SIP/2.0/UDP 169.48.232.158:5060;rport;branch=z9hG4bK5a0f6a079fa15290c7a5720af273776b
Max-Forwards: 70
From: "My Home Phoneline" <sip:15553215555@169.48.232.158>;tag=5e4d3a6ea638066c8bff3783e249fc56
To: <sip:15551235555@my.domain.com>;tag=6a5999a5-6e9e-4425-bbfb-1596c77819bd
Call-ID: 1QMAB9UBT91LD8F0UKL7VFCIUS@81.201.85.47-b2b_1
CSeq: 200 ACK
User-Agent: Anveo Callcontrol
Content-Length: 0

Still getting a busy signal, though.

Your log is incomplete. It can’t send an ACK until it has first sent an INVITE and you have responded with a status of 200 or greater.

The status code should indicate, in general terms, why Asterisk rejected the call.

Generally you should debug with at least verbose 3, and that should indicate why it gave the failure status.

If Asterisk is rejecting the call, post the final response from Asterisk to the INVITE request

Sorry about that. My laptop was in use by one of my kids, and so I was using my phone and neglected to copy the whole thing. I edited my previous response to reflect everything including the invite.

You didn’t include the INVITE, only the response.

It’s saying that you don’t have an extension 15553215555 in the context it thinks handles that endpoint. There should be a message, in the log, to that effect. If not, increase the verbosity.

I did:

asterisk -rvv
core set verbose 10
core set debug 10
sip set debug on

Here is everything else:

<--- Transmitting SIP request (410 bytes) to UDP:169.48.232.158:5060 --->
OPTIONS sip:sbc.anveo.com SIP/2.0
Via: SIP/2.0/UDP 10.142.0.3:5060;rport;branch=z9hG4bKPjcbfd0c46-eb42-4635-8475-4fb7af2e7fc5
From: <sip:siptrunk@10.142.0.3>;tag=947b18ae-8bcf-4bdd-b93d-0dba817e1db9
To: <sip:sbc.anveo.com>
Contact: <sip:siptrunk@10.142.0.3:5060>
Call-ID: 0e019b1a-e692-4a13-8431-c2bfa8582cab
CSeq: 65096 OPTIONS
Max-Forwards: 70
User-Agent: Asterisk PBX 16.22.0
Content-Length:  0


<--- Received SIP response (389 bytes) from UDP:169.48.232.158:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.142.0.3:5060;received=12.345.67.890;rport=5060;branch=z9hG4bKPjcbfd0c46-eb42-4635-8475-4fb7af2e7fc5
From: <sip:siptrunk@10.142.0.3>;tag=947b18ae-8bcf-4bdd-b93d-0dba817e1db9
To: <sip:sbc.anveo.com>;tag=da6d672eadbaa91350c1fadc9948769b
Call-ID: 0e019b1a-e692-4a13-8431-c2bfa8582cab
CSeq: 65096 OPTIONS
Server: Anveo Callcontrol
Content-Length: 0


<--- Transmitting SIP request (410 bytes) to UDP:169.48.232.158:5060 --->
OPTIONS sip:sbc.anveo.com SIP/2.0
Via: SIP/2.0/UDP 10.142.0.3:5060;rport;branch=z9hG4bKPja2a926d1-76b0-4bd4-aa2f-2b0bfae7f9f0
From: <sip:siptrunk@10.142.0.3>;tag=c47469e8-e17a-4876-944c-880cad5c5290
To: <sip:sbc.anveo.com>
Contact: <sip:siptrunk@10.142.0.3:5060>
Call-ID: 949cd730-e4e5-419d-be11-d3d685d31e3c
CSeq: 65317 OPTIONS
Max-Forwards: 70
User-Agent: Asterisk PBX 16.22.0
Content-Length:  0


<--- Received SIP response (389 bytes) from UDP:169.48.232.158:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.142.0.3:5060;received=12.345.67.890;rport=5060;branch=z9hG4bKPja2a926d1-76b0-4bd4-aa2f-2b0bfae7f9f0
From: <sip:siptrunk@10.142.0.3>;tag=c47469e8-e17a-4876-944c-880cad5c5290
To: <sip:sbc.anveo.com>;tag=1e3e6b72e46d2a20e556845fd20b5309
Call-ID: 949cd730-e4e5-419d-be11-d3d685d31e3c
CSeq: 65317 OPTIONS
Server: Anveo Callcontrol
Content-Length: 0


<--- Transmitting SIP request (410 bytes) to UDP:169.48.232.158:5060 --->
OPTIONS sip:sbc.anveo.com SIP/2.0
Via: SIP/2.0/UDP 10.142.0.3:5060;rport;branch=z9hG4bKPj17236031-18c7-4436-87df-1eda33f30389
From: <sip:siptrunk@10.142.0.3>;tag=a9115fcb-bc7f-47fe-9ae4-3f094f74d2a6
To: <sip:sbc.anveo.com>
Contact: <sip:siptrunk@10.142.0.3:5060>
Call-ID: c7bda8c4-aa97-4a42-b249-b41fe088ff47
CSeq: 39714 OPTIONS
Max-Forwards: 70
User-Agent: Asterisk PBX 16.22.0
Content-Length:  0


<--- Received SIP response (389 bytes) from UDP:169.48.232.158:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.142.0.3:5060;received=12.345.67.890;rport=5060;branch=z9hG4bKPj17236031-18c7-4436-87df-1eda33f30389
From: <sip:siptrunk@10.142.0.3>;tag=a9115fcb-bc7f-47fe-9ae4-3f094f74d2a6
To: <sip:sbc.anveo.com>;tag=f1ea4efce482c889df5d6850173893aa
Call-ID: c7bda8c4-aa97-4a42-b249-b41fe088ff47
CSeq: 39714 OPTIONS
Server: Anveo Callcontrol
Content-Length: 0


<--- Transmitting SIP request (410 bytes) to UDP:169.48.232.158:5060 --->
OPTIONS sip:sbc.anveo.com SIP/2.0
Via: SIP/2.0/UDP 10.142.0.3:5060;rport;branch=z9hG4bKPja6ea5792-080f-48df-9f39-c55f384b369b
From: <sip:siptrunk@10.142.0.3>;tag=a0ecbf8c-3176-47c8-aa04-869139aa741b
To: <sip:sbc.anveo.com>
Contact: <sip:siptrunk@10.142.0.3:5060>
Call-ID: d9d53d9a-4cac-480b-9e55-56ca93cbdfeb
CSeq: 17397 OPTIONS
Max-Forwards: 70
User-Agent: Asterisk PBX 16.22.0
Content-Length:  0


<--- Received SIP response (389 bytes) from UDP:169.48.232.158:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.142.0.3:5060;received=12.345.67.890;rport=5060;branch=z9hG4bKPja6ea5792-080f-48df-9f39-c55f384b369b
From: <sip:siptrunk@10.142.0.3>;tag=a0ecbf8c-3176-47c8-aa04-869139aa741b
To: <sip:sbc.anveo.com>;tag=666bcea10d32abc12a0f420c2ed44b36
Call-ID: d9d53d9a-4cac-480b-9e55-56ca93cbdfeb
CSeq: 17397 OPTIONS
Server: Anveo Callcontrol
Content-Length: 0

There is no INVITE, so there is no call

How do I add an invite? I assume I add a line or two or some sort of section to pjsip?

I got it! In extensions.conf I had:

[from-siptrunk]
exten => inbound-calls,1,Verbose(1,Playing some music.)
same => n,Answer
same => n,MusicOnHold(ulawstream)
same => n,Hangup()

But I had to change inbound-calls to my DID:

[from-siptrunk]
exten => 15551235555,1,Verbose(1,Playing some music.)
same => n,Answer
same => n,MusicOnHold(ulawstream)
same => n,Hangup()

Now it works!