Outgoing call: 401 Unauthorized followed by 488 Not Acceptable Here [for all outgoing numbers except one]

Hi,
I have a strange behaviour with my Asterisk configuration. Indeed, when I’m trying to dial out, only one number (+491…) is going through and for all the others I’m getting “401 Unauthorized” followed by “488 Not Acceptable Here” (i.e +492…).

This is quite strange because the rule is the same in my extension.conf
Can someone explain why do I have these error and only one number is going through?
Thank for your help

Extract of extension.conf

exten => _+49X.,1,Set(CALLERID(num)=+492XXXXXXXX10${CALLERID(num)})
same = n,Dial(PJSIP/mytrunk-out/sip:${EXTEN}@sip-trunk.server.com,120)

Extract of pjsip.conf

[transport-tls]
type=transport
protocol=tls
bind=0.0.0.0
local_net=192.168.0.190/255.255.255.254
external_media_address=7X.XX.XX.156
external_signaling_address=7X.XX.XX.156
tos=192
method=sslv23
ca_list_path=/etc/asterisk/keys/trustedcas
verify_server=false

[mytrunk-out]
type=endpoint
transport=transport-tls
context=dialplan
allow=!all,g722,alaw,ulaw
direct_media=yes
dtmf_mode=rfc4733
outbound_auth=trunk-auth
outbound_proxy=sip:reg.sip-trunk.server.com:5061\;transport=tls\;lr
from_domain=sip-trunk.server.com
media_encryption=sdes
send_pai=yes
aors=trunk-aor
rtp_symmetric=yes
force_rport=yes

“401 Unauthorized” followed by “488 Not Acceptable Here”

<--- Received SIP request (987 bytes) from UDP:192.168.0.181:36319 --->

INVITE sip:+492XXXXXXXX53@192.168.0.190 SIP/2.0

Via: SIP/2.0/UDP 192.168.0.181:36319;branch=z9hG4bK-524287-1---1179050dd8e80366;rport

Max-Forwards: 70

Contact: <sip:Gilles@192.168.0.181:36319>

To: <sip:+492XXXXXXXX53@192.168.0.190>

From: <sip:Gilles@192.168.0.190>;tag=ea3f0079

Call-ID: GwmNSpG-ZQcNEymbcbHfeQ..

CSeq: 1 INVITE

Session-Expires: 1800

Min-SE: 90

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, SUBSCRIBE, UPDATE, INFO, MESSAGE

Content-Type: application/sdp

Supported: path, replaces, timer, norefersub

User-Agent: SessionTalk 6.0

Content-Length: 397

v=0

o=- 0 1 IN IP4 192.168.0.250

s=-

c=IN IP4 192.168.0.181

t=0 0

m=audio 4034 RTP/AVP 9 0 8 3 102 120 101

a=rtpmap:9 G722/8000

a=rtpmap:0 PCMU/8000

a=rtpmap:8 PCMA/8000

a=rtpmap:3 GSM/8000

a=rtpmap:102 iLBC/8000

a=fmtp:102 mode=30

a=rtpmap:120 opus/48000/2

a=fmtp:120 useinbandfec=1; usedtx=1; maxaveragebitrate=64000

a=rtpmap:101 telephone-event/8000

a=fmtp:101 0-15

a=sendrecv

<--- Transmitting SIP response (533 bytes) to UDP:192.168.0.181:36319 --->

SIP/2.0 401 Unauthorized

Via: SIP/2.0/UDP 192.168.0.181:36319;rport=36319;received=192.168.0.181;branch=z9hG4bK-524287-1---1179050dd8e80366

Call-ID: GwmNSpG-ZQcNEymbcbHfeQ..

From: <sip:Gilles@192.168.0.190>;tag=ea3f0079

To: <sip:+492XXXXXXXX53@192.168.0.190>;tag=z9hG4bK-524287-1---1179050dd8e80366

CSeq: 1 INVITE

WWW-Authenticate: Digest realm="asterisk",nonce="1590136106/18dda955b9d6d133d53df292166b393d",opaque="5c39a6b645080a24",algorithm=md5,qop="auth"

Server: Asterisk PBX GIT-master-c8dec423d2M

Content-Length: 0

<--- Received SIP request (347 bytes) from UDP:192.168.0.181:36319 --->

ACK sip:+492XXXXXXXX53@192.168.0.190 SIP/2.0

Via: SIP/2.0/UDP 192.168.0.181:36319;branch=z9hG4bK-524287-1---1179050dd8e80366;rport

Max-Forwards: 70

To: <sip:+492XXXXXXXX53@192.168.0.190>;tag=z9hG4bK-524287-1---1179050dd8e80366

From: <sip:Gilles@192.168.0.190>;tag=ea3f0079

Call-ID: GwmNSpG-ZQcNEymbcbHfeQ..

CSeq: 1 ACK

Content-Length: 0

<--- Received SIP request (1283 bytes) from UDP:192.168.0.181:36319 --->

INVITE sip:+492XXXXXXXX53@192.168.0.190 SIP/2.0

Via: SIP/2.0/UDP 192.168.0.181:36319;branch=z9hG4bK-524287-1---0db77b5966e07e5c;rport

Max-Forwards: 70

Contact: <sip:Gilles@192.168.0.181:36319>

To: <sip:+492XXXXXXXX53@192.168.0.190>

From: <sip:Gilles@192.168.0.190>;tag=ea3f0079

Call-ID: GwmNSpG-ZQcNEymbcbHfeQ..

CSeq: 2 INVITE

Session-Expires: 1800

Min-SE: 90

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, SUBSCRIBE, UPDATE, INFO, MESSAGE

Content-Type: application/sdp

Supported: path, replaces, timer, norefersub

User-Agent: SessionTalk 6.0

Authorization: Digest username="Gilles",realm="asterisk",nonce="1590136106/18dda955b9d6d133d53df292166b393d",uri="sip:+492XXXXXXXX53@192.168.0.190",response="cc31b61b65b3f03c0b3e8665a0702e8f",cnonce="e277965bca925cb4b0e46980bbace391",nc=00000001,qop=auth,algorithm=md5,opaque="5c39a6b645080a24"

Content-Length: 397

v=0

o=- 0 1 IN IP4 192.168.0.250

s=-

c=IN IP4 192.168.0.181

t=0 0

m=audio 4034 RTP/AVP 9 0 8 3 102 120 101

a=rtpmap:9 G722/8000

a=rtpmap:0 PCMU/8000

a=rtpmap:8 PCMA/8000

a=rtpmap:3 GSM/8000

a=rtpmap:102 iLBC/8000

a=fmtp:102 mode=30

a=rtpmap:120 opus/48000/2

a=fmtp:120 useinbandfec=1; usedtx=1; maxaveragebitrate=64000

a=rtpmap:101 telephone-event/8000

a=fmtp:101 0-15

a=sendrecv

== Setting global variable 'SIPDOMAIN' to '192.168.0.190'

<--- Transmitting SIP response (341 bytes) to UDP:192.168.0.181:36319 --->

SIP/2.0 100 Trying

Via: SIP/2.0/UDP 192.168.0.181:36319;rport=36319;received=192.168.0.181;branch=z9hG4bK-524287-1---0db77b5966e07e5c

Call-ID: GwmNSpG-ZQcNEymbcbHfeQ..

From: <sip:Gilles@192.168.0.190>;tag=ea3f0079

To: <sip:+492XXXXXXXX53@192.168.0.190>

CSeq: 2 INVITE

Server: Asterisk PBX GIT-master-c8dec423d2M

Content-Length: 0

-- Executing [+492XXXXXXXX53@dialplan:1] Set("PJSIP/Gilles-00000006", "CALLERID(num)=+492XXXXXXXX10Gilles") in new stack

-- Executing [+492XXXXXXXX53@dialplan:2] Dial("PJSIP/Gilles-00000006", "PJSIP/mytrunk-out/sip:+492XXXXXXXX53@sip-trunk.server.com,120") in new stack

-- Called PJSIP/mytrunk-out/sip:+492XXXXXXXX53@sip-trunk.server.com

<--- Transmitting SIP request (1206 bytes) to TLS:2XX.XX.XX.XX:5061 --->

INVITE sip:+492XXXXXXXX53@sip-trunk.server.com SIP/2.0

Via: SIP/2.0/TLS 7X.XX.XX.156:5061;rport;branch=z9hG4bKPjd9b99719-d8a6-48e1-b384-b5533e84ed9d;alias

From: <sip:+492XXXXXXXX10Gilles@sip-trunk.server.com>;tag=0cbfbbd7-6b65-4577-9610-ff98eaeddd2c

To: <sip:+492XXXXXXXX53@sip-trunk.server.com>

Contact: <sip:+492XXXXXXXX10@7X.XX.XX.156:5061;transport=TLS>

Call-ID: cd8d8e82-c4f2-40a4-b656-c7fb8abf8689

CSeq: 29058 INVITE

Route: <sip:reg.sip-trunk.server.com:5061;transport=tls;lr>

Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER

Supported: 100rel, timer, replaces, norefersub

Session-Expires: 1800

Min-SE: 90

P-Asserted-Identity: <sip:+492XXXXXXXX10Gilles@sip-trunk.server.com>

Max-Forwards: 70

User-Agent: Asterisk PBX GIT-master-c8dec423d2M

Content-Type: application/sdp

Content-Length: 324

v=0

o=- 283098209 283098209 IN IP4 7X.XX.XX.156

s=Asterisk

c=IN IP4 7X.XX.XX.156

t=0 0

m=audio 15790 RTP/SAVP 0 101

a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:HM1YuKMf35faMNjGnDALdqTxx0UqOsdCyEV2YIqe

a=rtpmap:0 PCMU/8000

a=rtpmap:101 telephone-event/8000

a=fmtp:101 0-16

a=ptime:20

a=maxptime:150

a=sendrecv

<--- Received SIP response (354 bytes) from TLS:2XX.XX.XX.XX:5061 --->

SIP/2.0 100 Trying

Via: SIP/2.0/TLS 7X.XX.XX.156:5061;rport;branch=z9hG4bKPjd9b99719-d8a6-48e1-b384-b5533e84ed9d;alias

To: <sip:+492XXXXXXXX53@sip-trunk.server.com>

From: <sip:+492XXXXXXXX10Gilles@sip-trunk.server.com>;tag=0cbfbbd7-6b65-4577-9610-ff98eaeddd2c

Call-ID: cd8d8e82-c4f2-40a4-b656-c7fb8abf8689

CSeq: 29058 INVITE

Content-Length: 0

<--- Received SIP response (736 bytes) from TLS:2XX.XX.XX.XX:5061 --->

SIP/2.0 401 Unauthorized

Via: SIP/2.0/TLS 7X.XX.XX.156:5061;rport=55159;branch=z9hG4bKPjd9b99719-d8a6-48e1-b384-b5533e84ed9d;alias

To: <sip:+492XXXXXXXX53@sip-trunk.server.com>;tag=7478f630

From: <sip:+492XXXXXXXX10Gilles@sip-trunk.server.com>;tag=0cbfbbd7-6b65-4577-9610-ff98eaeddd2c

Call-ID: cd8d8e82-c4f2-40a4-b656-c7fb8abf8689

Contact: <sip:xQ7DjDTYoZ8S17Vq5X5pHc2AkQkB/6Ojy3JYxGpy5gUfPXYuzBM7hC4WjHCehdPpocVI@th1>

CSeq: 29058 INVITE

Allow: ACK, BYE, CANCEL, INVITE, MESSAGE, OPTIONS, PRACK, PUBLISH, REGISTER, SUBSCRIBE, UPDATE

WWW-Authenticate: Digest algorithm=MD5, nonce="6302e19b498f26c56302e19b6b6f189b8286064502b1bbb896f5fc53b23bf266", realm="sip-trunk.server.com"

Reason: TSSI;cause=4010001

Content-Length: 0

<--- Transmitting SIP request (526 bytes) to TLS:2XX.XX.XX.XX:5061 --->

ACK sip:+492XXXXXXXX53@sip-trunk.server.com SIP/2.0

Via: SIP/2.0/TLS 7X.XX.XX.156:5061;rport;branch=z9hG4bKPjd9b99719-d8a6-48e1-b384-b5533e84ed9d;alias

From: <sip:+492XXXXXXXX10Gilles@sip-trunk.server.com>;tag=0cbfbbd7-6b65-4577-9610-ff98eaeddd2c

To: <sip:+492XXXXXXXX53@sip-trunk.server.com>;tag=7478f630

Call-ID: cd8d8e82-c4f2-40a4-b656-c7fb8abf8689

CSeq: 29058 ACK

Route: <sip:reg.sip-trunk.server.com:5061;transport=tls;lr>

Max-Forwards: 70

User-Agent: Asterisk PBX GIT-master-c8dec423d2M

Content-Length: 0

<--- Transmitting SIP request (1464 bytes) to TLS:2XX.XX.XX.XX:5061 --->

INVITE sip:+492XXXXXXXX53@sip-trunk.server.com SIP/2.0

Via: SIP/2.0/TLS 7X.XX.XX.156:5061;rport;branch=z9hG4bKPj2e305df5-36e8-45c6-b422-7ceff424e893;alias

From: <sip:+492XXXXXXXX10Gilles@sip-trunk.server.com>;tag=0cbfbbd7-6b65-4577-9610-ff98eaeddd2c

To: <sip:+492XXXXXXXX53@sip-trunk.server.com>

Contact: <sip:+492XXXXXXXX10@7X.XX.XX.156:5061;transport=TLS>

Call-ID: cd8d8e82-c4f2-40a4-b656-c7fb8abf8689

CSeq: 29059 INVITE

Route: <sip:reg.sip-trunk.server.com:5061;transport=tls;lr>

Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER

Supported: 100rel, timer, replaces, norefersub

Session-Expires: 1800

Min-SE: 90

Max-Forwards: 70

User-Agent: Asterisk PBX GIT-master-c8dec423d2M

Authorization: Digest username="551126964215", realm="sip-trunk.server.com", nonce="6302e19b498f26c56302e19b6b6f189b8286064502b1bbb896f5fc53b23bf266", uri="sip:+492XXXXXXXX53@sip-trunk.server.com", response="e6e11679684c7e6ab3c94399f3f57d40", algorithm=MD5

P-Asserted-Identity: <sip:+492XXXXXXXX10Gilles@sip-trunk.server.com>

Content-Type: application/sdp

Content-Length: 324

v=0

o=- 283098209 283098209 IN IP4 7X.XX.XX.156

s=Asterisk

c=IN IP4 7X.XX.XX.156

t=0 0

m=audio 15790 RTP/SAVP 0 101

a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:HM1YuKMf35faMNjGnDALdqTxx0UqOsdCyEV2YIqe

a=rtpmap:0 PCMU/8000

a=rtpmap:101 telephone-event/8000

a=fmtp:101 0-16

a=ptime:20

a=maxptime:150

a=sendrecv

<--- Received SIP response (354 bytes) from TLS:2XX.XX.XX.XX:5061 --->

SIP/2.0 100 Trying

Via: SIP/2.0/TLS 7X.XX.XX.156:5061;rport;branch=z9hG4bKPj2e305df5-36e8-45c6-b422-7ceff424e893;alias

To: <sip:+492XXXXXXXX53@sip-trunk.server.com>

From: <sip:+492XXXXXXXX10Gilles@sip-trunk.server.com>;tag=0cbfbbd7-6b65-4577-9610-ff98eaeddd2c

Call-ID: cd8d8e82-c4f2-40a4-b656-c7fb8abf8689

CSeq: 29059 INVITE

Content-Length: 0

<--- Received SIP response (600 bytes) from TLS:2XX.XX.XX.XX:5061 --->

SIP/2.0 488 Not Acceptable Here

Via: SIP/2.0/TLS 7X.XX.XX.156:5061;rport=55159;branch=z9hG4bKPj2e305df5-36e8-45c6-b422-7ceff424e893;alias

To: <sip:+492XXXXXXXX53@sip-trunk.server.com>;tag=fafe789d

From: <sip:+492XXXXXXXX10Gilles@sip-trunk.server.com>;tag=0cbfbbd7-6b65-4577-9610-ff98eaeddd2c

Call-ID: cd8d8e82-c4f2-40a4-b656-c7fb8abf8689

Contact: <sip:xQ7DjDTYoZ8S17Vq5X5pHc2AkQkB/6Ojy3JYxGpy5gUfPXYuzBM7hC4WjHCehdPpocVI@th1>

CSeq: 29059 INVITE

Allow: ACK, BYE, CANCEL, INVITE, MESSAGE, OPTIONS, PRACK, PUBLISH, REFER, REGISTER, SUBSCRIBE, UPDATE

Reason: TSSI;cause=0

Content-Length: 0

<--- Transmitting SIP request (526 bytes) to TLS:2XX.XX.XX.XX:5061 --->

ACK sip:+492XXXXXXXX53@sip-trunk.server.com SIP/2.0

Via: SIP/2.0/TLS 7X.XX.XX.156:5061;rport;branch=z9hG4bKPj2e305df5-36e8-45c6-b422-7ceff424e893;alias

From: <sip:+492XXXXXXXX10Gilles@sip-trunk.server.com>;tag=0cbfbbd7-6b65-4577-9610-ff98eaeddd2c

To: <sip:+492XXXXXXXX53@sip-trunk.server.com>;tag=fafe789d

Call-ID: cd8d8e82-c4f2-40a4-b656-c7fb8abf8689

CSeq: 29059 ACK

Route: <sip:reg.sip-trunk.server.com:5061;transport=tls;lr>

Max-Forwards: 70

User-Agent: Asterisk PBX GIT-master-c8dec423d2M

Content-Length: 0

== Everyone is busy/congested at this time (1:0/0/1)

-- Auto fallthrough, channel 'PJSIP/Gilles-00000006' status is 'CHANUNAVAIL'

<--- Transmitting SIP response (419 bytes) to UDP:192.168.0.181:36319 --->

SIP/2.0 503 Service Unavailable

Via: SIP/2.0/UDP 192.168.0.181:36319;rport=36319;received=192.168.0.181;branch=z9hG4bK-524287-1---0db77b5966e07e5c

Call-ID: GwmNSpG-ZQcNEymbcbHfeQ..

From: <sip:Gilles@192.168.0.190>;tag=ea3f0079

To: <sip:+492XXXXXXXX53@192.168.0.190>;tag=0f746528-d488-4dd6-9537-5f121661f6b9

CSeq: 2 INVITE

Server: Asterisk PBX GIT-master-c8dec423d2M

Reason: Q.850;cause=34

Content-Length: 0

<--- Received SIP request (348 bytes) from UDP:192.168.0.181:36319 --->

ACK sip:+492XXXXXXXX53@192.168.0.190 SIP/2.0

Via: SIP/2.0/UDP 192.168.0.181:36319;branch=z9hG4bK-524287-1---0db77b5966e07e5c;rport

Max-Forwards: 70

To: <sip:+492XXXXXXXX53@192.168.0.190>;tag=0f746528-d488-4dd6-9537-5f121661f6b9

From: <sip:Gilles@192.168.0.190>;tag=ea3f0079

Call-ID: GwmNSpG-ZQcNEymbcbHfeQ..

CSeq: 2 ACK

Content-Length: 0

There’s nothing out of the ordinary on the Asterisk side. It’s the remote side responding with this, so you’d need to inquire with them to determine why.

401 is not an error.

I was seeing these 401 errors when everything appeared to be working OK. I eventually found another thread which indicated that I needed an entry in the context for the trunk which essentially did nothing. In your situation you might try adding exten mytrunk-out,1,hangup in the dialplan context and it might get rid of the 401 (non) errors and remove the potential confusion.

Good morning,
Just found the origin of my issue: Again related to codecs.
My outgoing trunk codecs was defined as: allow=!all,g722,alaw,ulaw.
but the endpoint related to my VOIP software was different (only ulaw was allowed).

Then, due to this limitation, some numbers (depending on the final PBX) were going through and some others not. Duplicating to all the endpoints, the same codecs (allow=!all,g722,alaw,ulaw) fixed the issue.

Thanks again for your help