Asterisk kamailio


#1

Hi,
I am using kamailio to load balance asterisk servers. All register request are forwarded to one asterisk which is storing contact details in database. Now on receiving INVITE, kamailio is selecting asterisk server in round robin fashion. I was hoping other asterisk server could read contact details from database. In my case contact details are getting populated in ps_contacts table, but when making sip call following error is coming
“Everyone is busy/congested at this time (1:0/0/1)
– Auto fallthrough, channel ‘xyz’ status is ‘CHANUNAVAIL’”.

And this error is only coming when the INVITE gets forwarded to asterisk which did not register the device.


#2

You haven’t stated your configuration. Are you using sorcery caching? What is the sorcery configuration? Have you looked at the CLI output of “pjsip show contacts” to see if they can be listed on the other server?


#3

Sorcery.conf file:

[test_sorcery_section]
test=memory

[test_sorcery_cache]
test/cache=test
test=memory

[res_pjsip]
endpoint=realtime,ps_endpoints
;auth=realtime,ps_auths
aor=realtime,ps_aors
domain_alias=realtime,ps_domain_aliases
contact=realtime,ps_contacts

auth=config,pjsip.conf,criteria=type=auth
domain_alias=config,pjsip.conf,criteria=type=domain_alias
global=config,pjsip.conf,criteria=type=global
system=config,pjsip.conf,criteria=type=system
transport=config,pjsip.conf,criteria=type=transport
contact=astdb,registrator

[res_pjsip_endpoint_identifier_ip]
identify=realtime,ps_endpoint_id_ips
identify=config,pjsip.conf,criteria=type=identify

[res_pjsip_outbound_publish]
outbound-publish=config,pjsip.conf,criteria=type=outbound-publish

[res_pjsip_outbound_registration]
registration=config,pjsip.conf,criteria=type=registration


#4

pjsip show contacts output:
These two endpoints are stored in database. And this output is from other server where register request is not sent

Contact: <Aor/ContactUri…> <Hash…> <RTT(ms)…>

Contact: 6000/sip:6000@34.215.xxx.xx:5060 0d762793d6 Created 0.000
Contact: 6001/sip:6001@34.215.xxx.xx:5060 272aebbc0a Created 0.000


#5

Hello,

  are you tried using pjsip_dial_contacts function instead of DIAL application?

regards


#6

Is qualify enabled? It may be because of that. Like I stated originally though, this isn’t something that to my knowledge anyone has explicitly worked on.


#7

I added exten => _6XXX, 1 ,Dial(${PJSIP_DIAL_CONTACTS(${EXTEN})}) in the extensions.conf file. And following output is coming repeatedly and call could not get placed.

– Executing [6000@outgoing:1] Dial(“PJSIP/6001-0000012c”, “PJSIP/6000/sip:6000@34.215.xxx.xx:5060”) in new stack
== Spawn extension (outgoing, 6000, 1) exited non-zero on ‘PJSIP/6001-00000126’
== Spawn extension (outgoing, 6000, 1) exited non-zero on ‘PJSIP/6001-00000128’
– Called PJSIP/6000/sip:6000@34.215.xxx.xx:5060
== DTLS ECDH initialized (automatic), faster PFS enabled
== Spawn extension (outgoing, 6000, 1) exited non-zero on ‘PJSIP/6001-0000012a’
== Setting global variable ‘SIPDOMAIN’ to ‘34.215.xxx.xx’
== DTLS ECDH initialized (automatic), faster PFS enabled
– Executing [6000@outgoing:1] Dial(“PJSIP/6001-0000012e”, “PJSIP/6000/sip:6000@34.215.xxx.xx:5060”) in new stack
== Spawn extension (outgoing, 6000, 1) exited non-zero on ‘PJSIP/6001-0000012c’
– Called PJSIP/6000/sip:6000@34.215.xxx.xx:5060
== DTLS ECDH initialized (automatic), faster PFS enabled
== Spawn extension (outgoing, 6000, 1) exited non-zero on ‘PJSIP/6001-0000012e’
== Setting global variable ‘SIPDOMAIN’ to ‘34.215.xxx.xx’
== DTLS ECDH initialized (automatic), faster PFS enabled
– Executing [6000@outgoing:1] Dial(“PJSIP/6001-00000130”, “PJSIP/6000/sip:6000@34.215.xxx.xx:5060”) in new stack
– Caller hung up before dial.
== Spawn extension (outgoing, 6000, 1) exited non-zero on ‘PJSIP/6001-00000130’


#8

Does it actually attempt to send the SIP requests? (pjsip set logger on will output them)


#9

I am getting following output

== DTLS ECDH initialized (automatic), faster PFS enabled
– Executing [6000@outgoing:1] Dial(“PJSIP/6001-00000e67”, “PJSIP/6000”) in new stack
– Called PJSIP/6000
== DTLS ECDH initialized (automatic), faster PFS enabled
<— Transmitting SIP request (1660 bytes) to UDP:34.215.xxx.xx:5060 —>

INVITE sip:6000@34.215.xxx.xx:5060 SIP/2.0
Record-Route: sip:34.215.xxx.xx:5060;ftag=ae6ca3d1-76d0-403a-939a-adee129a2b5a;lr=on
Via: SIP/2.0/UDP 34.215.xxx.xx:5060;branch=z9hG4bKe497.a8ee909c7a8aa8d447a3f220efd4e5d7.0
Via: SIP/2.0/UDP 34.215.xxx.xx:5060;received=54.202.xxx.xx;rport=5060;branch=z9hG4bKPjd6345946-e6d4-49ed-a885-bf74f7be1b0f
From: “6001” sip:6001@172.31.xxx.xx;tag=ae6ca3d1-76d0-403a-939a-adee129a2b5a
To: sip:6000@34.215.xxx.xx
Contact: sip:asterisk@54.202.xxx.xx:5060
Call-ID: 10bd6514-30e3-4246-b379-986e91e7afa4
CSeq: 8142 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 69
User-Agent: Asterisk PBX 15.5.0
Content-Type: application/sdp
Content-Length: 999

v=0
o=- 476753739 476753739 IN IP4 172.31.xxx.xx
s=Asterisk
c=IN IP4 172.31.xxx.xx
t=0 0
m=audio 12434 UDP/TLS/RTP/SAVPF 0 101
a=connection:new
a=setup:actpass
a=fingerprint:SHA-256 82:1F:48:AE:87:31:37:3F:6A:AE:F8:64:B5:B4:7F:3C:3C:AA:D1:5E:BB:7C:F6:04:75:D8:AB:B6:66:08:B1:93
a=ice-ufrag:3132d1907fe16f9e3ae54c690253e2cd
a=ice-pwd:5516ba0846b2d01177cc9aa12bd8b378
a=candidate:H96bb4088 1 UDP 2130706431 fe80::4e5:f3ff:fe70:33e 12434 typ host
a=candidate:Hac1f144f 1 UDP 2130706431 172.31.xxx.xx 12434 typ host
a=candidate:S36ca91df 1 UDP 1694498815 54.202.xxx.xx 12434 typ srflx raddr 172.31.xxx.xx rport 12434
a=candidate:H96bb4088 2 UDP 2130706430 fe80::4e5:f3ff:fe70:33e 12435 typ host
a=candidate:Hac1f144f 2 UDP 2130706430 172.31.xxx.xx 12435 typ host
a=candidate:S36ca91df 2 UDP 1694498814 54.202.xxx.xx 12435 typ srflx raddr 172.31.xxx.xx rport 12435
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
a=rtcp-mux

<— Transmitting SIP request (412 bytes) to UDP:34.215.xxx.xx:5060 —>
CANCEL sip:6000@34.215.xxx.xx:5060 SIP/2.0
Via: SIP/2.0/UDP 34.215.xxx.xx:5060;rport;branch=z9hG4bKPje83df276-d530-46db-ad1b-9589c7ef80d7
From: “6001” sip:6001@172.31.xxx.xx;tag=10300a10-2e17-4a56-826f-f14891ebc38e
To: sip:6000@34.215.xxx.xx
Call-ID: ce4adec8-e378-4221-881b-1208d14c1247
CSeq: 23636 CANCEL
Reason: Q.850;cause=0
Max-Forwards: 70
User-Agent: Asterisk PBX 15.5.0
Content-Length: 0

<— Received SIP request (372 bytes) from UDP:34.215.xxx.xx:5060 —>
CANCEL sip:6000@34.215.xxx.xx:5060 SIP/2.0
Via: SIP/2.0/UDP 34.215.xxx.xx:5060;branch=z9hG4bK744.b630d4e458ec53bd4b4f7a27993adb0c.0
From: “6001” sip:6001@172.31.xxx.xx;tag=10300a10-2e17-4a56-826f-f14891ebc38e
To: sip:6000@34.215.xxx.xx
Call-ID: ce4adec8-e378-4221-881b-1208d14c1247
CSeq: 23636 CANCEL
Max-Forwards: 69
Content-Length: 0
Reason: Q.850;cause=0


#10

If the INVITE is one sent from Asterisk, then it appears to be trying to establish a call but getting no response.


#11

And output is coming in a loop. And finally asterisk server is getting crashed.

== Setting global variable ‘SIPDOMAIN’ to ‘34.215.xxx.xx’
<— Transmitting SIP response (582 bytes) to UDP:34.215.xxx.xx:5060 —>
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 34.215.xxx.xx:5060;rport=5060;received=34.215.xxx.xx;branch=z9hG4bK2576.76d6c78710bc6bd242ca99dbf231fdc3.0
Via: SIP/2.0/UDP 34.215.xxx.xx:5060;rport=5060;received=54.202.xxx.xxx;branch=z9hG4bKPj54d05534-845f-4be9-84e1-e72b717e1070
Record-Route: sip:34.215.xxx.xx:5060;lr;ftag=41fd0523-a023-490e-995e-1ad5c9b09664
Call-ID: aad5d317-6f69-499e-89ae-4f50d3cb6b7a
From: “6001” sip:6001@172.31.xx.xx;tag=41fd0523-a023-490e-995e-1ad5c9b09664
To: sip:6000@34.215.xxx.xx
CSeq: 28722 INVITE
Server: Asterisk PBX 15.5.0
Content-Length: 0

Disconnected from Asterisk server.

In the above message via header is appearing twice and both have same ip. Is it possible that because of this it is falling in a loop.


#12

Yes. You haven’t described what IPs are what or the layout of things, so it is entirely possible that it is looping.


#13

Actually looping issue has appeared now. Earlier I was getting channel unavailable error.


#14

I have one kamailio server with ip 34.215.xxx.xx
2 asterisk server with ip 34.220.xx.xx and 54.202.xxx.xx
first asterisk is registering all the requests and then all invite requests are load balanced using round robin method.
I have created a common RDS instance and contact details are stored in ‘ps_contacts’ table.
I am making sip calls from a private network. When call is getting forwarded to first asterisk everything is working fine, but when it is forwarded to second asterisk it is showing channel unavailable error. And surprisingly now I am getting above output in a loop.


#15

Then you’re going to need to look at the entire flow, including Kamailio, and understand why a loop is occurring.


#16

I think there was some issue with my endpoint. After changing endpoints I am getting following error. INVITE request is actually sent 3 times before giving error.

<— Received SIP request (1878 bytes) from UDP:34.215.xxx.xx:5060 —>
INVITE sip:sipML5@34.215.xxx.xx:5060 SIP/2.0
Record-Route: sip:34.215.xxx.xx:5060;ftag=8f4fe7f6-c204-47db-9ef0-32e333b84277;lr=on
Via: SIP/2.0/UDP 34.215.xxx.xx:5060;branch=z9hG4bKc28e.1354185996669af1e04018d4151b77af.0
Via: SIP/2.0/UDP 34.215.xxx.xx:5060;received=54.202.xxx.xx;rport=5060;branch=z9hG4bKPjf4b0eda5-76c4-468d-8dd6-49cfb6873de1
From: “zoiper” sip:zoiper@172.31.xxx.xx;tag=8f4fe7f6-c204-47db-9ef0-32e333b84277
To: sip:sipML5@34.215.xxx.xx
Contact: sip:asterisk@54.202.xxx.xx:5060
Call-ID: 01975931-748a-4d92-9fb4-3aed35844a1e
CSeq: 6667 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 69
User-Agent: Asterisk PBX 15.5.0
Content-Type: application/sdp
Content-Length: 1001

v=0
o=- 2143251701 2143251701 IN IP4 172.31.xxx.xx
s=Asterisk
c=IN IP4 172.31.xxx.xx
t=0 0
m=audio 18492 UDP/TLS/RTP/SAVPF 0 101
a=connection:new
a=setup:actpass
a=fingerprint:SHA-256 82:1F:48:AE:87:31:37:3F:6A:AE:F8:64:B5:B4:7F:3C:3C:AA:D1:5E:BB:7C:F6:04:75:D8:AB:B6:66:08:B1:93
a=ice-ufrag:24d80613151ecd761e446fdd641d9cf4
a=ice-pwd:16e05be64ef34dbf08ce6a173341a3ad
a=candidate:H96bb4088 1 UDP 2130706431 fe80::4e5:f3ff:fe70:33e 18492 typ host
a=candidate:Hac1f144f 1 UDP 2130706431 172.31.xxx.xx 18492 typ host
a=candidate:S36ca91df 1 UDP 1694498815 54.202.xxx.xx 18492 typ srflx raddr 172.31.xxx.xx rport 18492
a=candidate:H96bb4088 2 UDP 2130706430 fe80::4e5:f3ff:fe70:33e 18493 typ host
a=candidate:Hac1f144f 2 UDP 2130706430 172.31.xxx.xx 18493 typ host
a=candidate:S36ca91df 2 UDP 1694498814 54.202.xxx.xx 18493 typ srflx raddr 172.31.xxx.xx rport 18493
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
a=rtcp-mux

<— Transmitting SIP response (631 bytes) to UDP:34.215.xxx.xx:5060 —>
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 34.215.xxx.xx:5060;rport=5060;received=34.215.xxx.xx;branch=z9hG4bKc28e.1354185996669af1e04018d4151b77af.0
Via: SIP/2.0/UDP 34.215.xxx.xx:5060;rport=5060;received=54.202.xxx.xx;branch=z9hG4bKPjf4b0eda5-76c4-468d-8dd6-49cfb6873de1
Record-Route: sip:34.215.xxx.xx:5060;lr;ftag=8f4fe7f6-c204-47db-9ef0-32e333b84277
Call-ID: 01975931-748a-4d92-9fb4-3aed35844a1e
From: “zoiper” sip:zoiper@172.31.xxx.xx;tag=8f4fe7f6-c204-47db-9ef0-32e333b84277
To: sip:sipML5@34.215.xxx.xx;tag=a19f26c5-bfce-409d-9ee4-88cb7ec605bf
CSeq: 6667 INVITE
Server: Asterisk PBX 15.5.0
Content-Length: 0

<— Received SIP request (392 bytes) from UDP:34.215.xxx.xx:5060 —>
ACK sip:sipML5@34.215.xxx.xx:5060 SIP/2.0
Via: SIP/2.0/UDP 34.215.xxx.xx:5060;branch=z9hG4bKc28e.1354185996669af1e04018d4151b77af.0
From: “zoiper” sip:zoiper@172.31.xxx.xx;tag=8f4fe7f6-c204-47db-9ef0-32e333b84277
To: sip:sipML5@34.215.xxx.xx;tag=a19f26c5-bfce-409d-9ee4-88cb7ec605bf
Call-ID: 01975931-748a-4d92-9fb4-3aed35844a1e
CSeq: 6667 ACK
Max-Forwards: 69
Content-Length: 0

<— Received SIP response (506 bytes) from UDP:34.215.xxx.xx:5060 —>
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 34.215.xxx.xx:5060;rport=5060;received=54.202.xxx.xx;branch=z9hG4bKPjf4b0eda5-76c4-468d-8dd6-49cfb6873de1
Record-Route: sip:34.215.xxx.xx:5060;lr;ftag=8f4fe7f6-c204-47db-9ef0-32e333b84277
Call-ID: 01975931-748a-4d92-9fb4-3aed35844a1e
From: “zoiper” sip:zoiper@172.31.xxx.xx;tag=8f4fe7f6-c204-47db-9ef0-32e333b84277
To: sip:sipML5@34.215.xxx.xx;tag=a19f26c5-bfce-409d-9ee4-88cb7ec605bf
CSeq: 6667 INVITE
Server: Asterisk PBX 15.5.0
Content-Length: 0

<— Transmitting SIP request (431 bytes) to UDP:34.215.xxx.xx:5060 —>
ACK sip:sipML5@34.215.xxx.xx:5060 SIP/2.0
Via: SIP/2.0/UDP 34.215.xxx.xx:5060;rport;branch=z9hG4bKPjf4b0eda5-76c4-468d-8dd6-49cfb6873de1
From: “zoiper” sip:zoiper@172.31.xxx.xx;tag=8f4fe7f6-c204-47db-9ef0-32e333b84277
To: sip:sipML5@34.215.xxx.xx;tag=a19f26c5-bfce-409d-9ee4-88cb7ec605bf
Call-ID: 01975931-748a-4d92-9fb4-3aed35844a1e
CSeq: 6667 ACK
Max-Forwards: 70
User-Agent: Asterisk PBX 15.5.0
Content-Length: 0

== Everyone is busy/congested at this time (1:0/0/1)
– Auto fallthrough, channel ‘PJSIP/zoiper-00000773’ status is ‘CHANUNAVAIL’
<— Transmitting SIP response (627 bytes) to UDP:34.215.xxx.xx:5060 —>
SIP/2.0 503 Service Unavailable
Via: SIP/2.0/UDP 34.215.xxx.xx:5060;rport=5060;received=34.215.xxx.xx;branch=z9hG4bKf433.7f11e9753bddf58500352f45c72d5c51.0
Via: SIP/2.0/WSS df7jal23ls0d.invalid;rport=33474;received=103.211.39.31;branch=z9hG4bKTG2KDxCq3r2QIsbgrndrncoxRn4AGlOA
Record-Route: sip:34.215.xxx.xx:5060;lr;ftag=LkHCpR6QISZ89MHTlzke
Call-ID: 4c8e2afb-6f38-116c-f6bc-f8127c0cbe91
From: “zoiper” sip:zoiper@34.215.xxx.xx;tag=LkHCpR6QISZ89MHTlzke
To: sip:101@34.215.xxx.xx;tag=5f5b9074-114e-4727-a919-db0df6ec1fe1
CSeq: 3918 INVITE
Server: Asterisk PBX 15.5.0
Reason: Q.850;cause=34
Content-Length: 0

<— Received SIP request (365 bytes) from UDP:34.215.xxx.xx:5060 —>
ACK sip:101@34.215.xxx.xx SIP/2.0
Via: SIP/2.0/UDP 34.215.xxx.xx:5060;branch=z9hG4bKf433.7f11e9753bddf58500352f45c72d5c51.0
From: "zoiper"sip:zoiper@34.215.xxx.xx;tag=LkHCpR6QISZ89MHTlzke
To: sip:101@34.215.xxx.xx;tag=5f5b9074-114e-4727-a919-db0df6ec1fe1
Call-ID: 4c8e2afb-6f38-116c-f6bc-f8127c0cbe91
CSeq: 3918 ACK
Content-Length: 0
Max-Forwards: 69


#17

Did you look at the SIP trace at all yourself or just paste it here? You need to be able to read and understand such things if you are deploying/using SIP.


#18

I have got 404 NOT FOUND error also above but endpoint entry is there in table.


#19

Have you followed the full communication because it still seems to be looping. As well it is dialing extension “sipML5” which would need to exist in the Asterisk dialplan. Simply being a configured PJSIP endpoint doesn’t make it exist in the dialplan unless you’ve written logic to do so.


#20

I have added ‘sipML5’ endpoint in dialplan. And my concern is in INVITE request asterisk is changing the contact field. If you see INVITE request contact filed is “Contact: sip:asterisk@54.202.xxx.xx:5060” .
It should be endpoint to which we are calling and not asterisk. For that I have set rewrite_contact so no, still the issue persist.