Asterisk 404 response

Hi,

I am trying to write my first Asterisk Testsuite test case. I don’t understand why I receive 404 response from asterisk instance 1.
My goal is that UAC call extension 2222 on ast2. Ext 2222 will answer the call and playback hello-world. Ext 2222 will then hangup the call, and UAC will reply 200 OK.

Topology:
UAC > ast1 > ast2

Is there anything wrong in general with my test case or configuration?

Best regards,
malacho

Configuration files:
run-test:

#!/usr/bin/env python

import sys
import os
import logging

sys.path.append("lib/python")

from asterisk.test_case import TestCase
from asterisk.sipp import SIPpScenario
from twisted.internet import reactor

LOGGER = logging.getLogger(__name__)
TEST_DIR = os.path.dirname(os.path.realpath(__file__))


class DialTest(TestCase):

    def __init__(self):
        super(DialTest, self).__init__()

        self.events_passed = 0
        self.expected_events_passed = 1

        self.connectionEstablished = 0

        self.create_asterisk(count=2)

        self.sipp_scenario = {'scenario': 'dial.xml',
                              '-inf': 'users.csv'}

    def ami_connect(self, ami):
        TestCase.ami_connect(self, ami)
        self.connectionEstablished += 1

        if ami.id == 1:
            self.ami[1].registerEvent('UserEvent', self.playback_event)

        if self.connectionEstablished != 2:
            return

        LOGGER.warning("CONNECTIONS: {}".format(self.connectionEstablished))

        self.execute_scenario()

    def execute_scenario(self):

        self.sipp_scenario = SIPpScenario(TEST_DIR, self.sipp_scenario)
        self.sipp_scenario.run(self)

    def playback_event(self, ami, event):

        if event['userevent'] != 'PlaybackResult':
            return

        if event['result'] == "pass":
            self.events_passed += 1

        self.check_passed()

    def check_passed(self):
        LOGGER.warning("CHECK_EVENTS_PASSED: {}".format(self.events_passed))
        if self.events_passed == self.expected_events_passed:
            self.set_passed(True)
            self.stop_reactor()

    def run(self):
        super(DialTest, self).run()
        self.create_ami_factory(count=2)


def main():
    test = DialTest()
    reactor.run()

    if not test.passed:
        return 1
    return 0


if __name__ == "__main__":
    sys.exit(main())

ast1 sip.conf:

[general]
bindaddress=127.0.0.1
sipdebug=yes
disallow=all
allow=ulaw

[ast2]
type=friend
host=127.0.0.2
context=dialtest
qualify=no
insecure=invite

[1111]
type=friend
qualify=no
host=dynamic
context=dialtest
canreinvite=yes
insecure=invite

ast1 extensions.conf:

[dialtest]

exten => 2222,1,NoOp()
    same => n,Dial(SIP/2222@ast2,20)
    same => n,Hangup()

ast2 sip.conf:

[general]
bindaddress=127.0.0.2
sipdebug=yes
disallow=all
allow=ulaw

[ast1]
type=friend
host=127.0.0.1
context=ast2-incoming
qualify=no
insecure=invite

ast2 extensions.conf:

[ast2-incoming]

exten => 2222,1,NoOp()
    same => n,Answer()
    same => n,Playback(hello-world)
    same => n,ExecIf($[${PLAYBACKSTATUS}=SUCCESS]?UserEvent(PlaybackResult,result:pass)
    same => n,Hangup()

sipp xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">

<scenario name="Dial Test">

    <send retrans="500">
        <![CDATA[

        INVITE sip:[field1]@[remote_ip]:[remote_port] SIP/2.0
        Via: SIP/2.0/[transport] [local_ip]:[local_port]
        From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number]
        To: [field1] <sip:[field1]@[remote_ip]:[remote_port]>
        Call-ID: [call_id]
        Cseq: 1 INVITE
        Contact: sip:[field0]@[local_ip]:[local_port]
        Content-Type: application/sdp
        Content-Length: [len]

        v=0
        o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
        s=-
        t=0 0
        c=IN IP[media_ip_type] [media_ip]
        m=audio [media_port] RTP/AVP 0
        a=rtpmap:0 PCMU/8000

        ]]>
    </send>

    <recv response="100" optional="true">
    </recv>

    <recv response="180" optional="true">
    </recv>

    <recv response="200">
    </recv>

    <send retrans="500">
        <![CDATA[

        ACK sip:[field1]@[remote_ip]:[remote_port] SIP/2.0
        Via: SIP/2.0/[transport] [local_ip]:[local_port]
        From: [field0] <sip:[field0]@[local_ip]:[local_port]>;tag=[call_number]
        To: [field1] <sip:[field1]@[remote_ip]:[remote_port]>[peer_tag_param]
        Call-ID: [call_id]
        Cseq: 1 ACK
        Contact: sip:[field0]@[local_ip]:[local_port]
        Content-Length: 0

        ]]>

    </send>

    <recv request="BYE">
    </recv>

    <send retrans="500">
        <![CDATA[

        SIP/2.0 200 OK
        [last_Via:]
        [last_From:]
        [last_To:]
        [last_Call-ID:]
        [last_CSeq:]
        Contact: <sip:[local_ip]:[local_port];transport=[transport]>
        Content-Length: 0

        ]]>
    </send>

</scenario>

users.csv:

SEQUENTIAL
1111;2222;

Questions like this are best placed on the asterisk-dev mailing list[1] but have you examined any of the Asterisk logs to see if things are being matched and what is happening?

[1] http://lists.digium.com/mailman/listinfo/asterisk-dev

HI jcolp,

Looking in log from ast2, I can see that it receive the invite, but cannot locate the extension.
In ast2 sip.conf I have context=ast2-incoming, and in ast2 extensions.conf extension 2222 is located in ast2-incoming context.

Am I missing something here?

Best regards,
malacho

[Feb 18 15:34:46] VERBOSE[3462] chan_sip.c:
<— SIP read from UDP:127.0.0.1:5061 —>
INVITE sip:2222@127.0.0.1:5060 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:5061
From: 1111 sip:1111@127.0.0.1:5061;tag=1
To: 2222 sip:2222@127.0.0.1:5060
Call-ID: 1-3501@127.0.0.1
Cseq: 1 INVITE
Contact: sip:1111@127.0.0.1:5061
Content-Type: application/sdp
Content-Length: 130
v=0
o=user1 53655765 2353687637 IN IP4 127.0.0.1
s=-
t=0 0
c=IN IP4 127.0.0.1
m=audio 36663 RTP/AVP 0
a=rtpmap:0 PCMU/8000
<------------->
[Feb 18 15:34:46] VERBOSE[3462] chan_sip.c: — (9 headers 7 lines) —
[Feb 18 15:34:46] VERBOSE[3462] chan_sip.c: Sending to 127.0.0.1:5061 (no NAT)
[Feb 18 15:34:46] VERBOSE[3462][C-00000001] chan_sip.c: Sending to 127.0.0.1:5061 (no NAT)
[Feb 18 15:34:46] VERBOSE[3462][C-00000001] chan_sip.c: Using INVITE request as basis request - 1-3501@127.0.0.1
[Feb 18 15:34:46] VERBOSE[3462][C-00000001] chan_sip.c: No matching peer for ‘1111’ from ‘127.0.0.1:5061’
[Feb 18 15:34:46] VERBOSE[3462][C-00000001] netsock2.c: Using SIP RTP CoS mark 5
[Feb 18 15:34:46] VERBOSE[3462][C-00000001] chan_sip.c: Found RTP audio format 0
[Feb 18 15:34:46] VERBOSE[3462][C-00000001] chan_sip.c: Found audio description format PCMU for ID 0
[Feb 18 15:34:46] VERBOSE[3462][C-00000001] chan_sip.c: Capabilities: us - (ulaw), peer - audio=(ulaw)/video=(nothing)/text=(nothing), combined - (ulaw)
[Feb 18 15:34:46] VERBOSE[3462][C-00000001] chan_sip.c: Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x0 (nothing), combined - 0x0 (nothing)
[Feb 18 15:34:46] VERBOSE[3462][C-00000001] res_rtp_asterisk.c: 0x7f102800a390 – Strict RTP learning after remote address set to: 127.0.0.1:36663
[Feb 18 15:34:46] VERBOSE[3462][C-00000001] chan_sip.c: Peer audio RTP is at port 127.0.0.1:36663
[Feb 18 15:34:46] VERBOSE[3462][C-00000001] chan_sip.c: Looking for 2222 in default (domain 127.0.0.1)
[Feb 18 15:34:46] VERBOSE[3462][C-00000001] chan_sip.c:
<— Reliably Transmitting (no NAT) to 127.0.0.1:5061 —>
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 127.0.0.1:5061;received=127.0.0.1
From: 1111 sip:1111@127.0.0.1:5061;tag=1
To: 2222 sip:2222@127.0.0.1:5060;tag=as68558337
Call-ID: 1-3501@127.0.0.1
CSeq: 1 INVITE
Server: Asterisk PBX 16.7.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Length: 0
<------------>
[Feb 18 15:34:46] NOTICE[3462][C-00000001] chan_sip.c: Call from ‘’ (127.0.0.1:5061) to extension ‘2222’ rejected because extension not found in context ‘default’.
[Feb 18 15:34:46] VERBOSE[3462][C-00000001] chan_sip.c: Scheduling destruction of SIP dialog ‘1-3501@127.0.0.1’ in 32000 ms (Method: INVITE)
[Feb 18 15:34:46] VERBOSE[3462] chan_sip.c:
<— SIP read from UDP:127.0.0.1:5061 —>
ACK sip:2222@127.0.0.1:5060 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:5061;received=127.0.0.1
From: 1111 sip:1111@127.0.0.1:5061;tag=1
To: 2222 sip:2222@127.0.0.1:5060;tag=as68558337
Call-ID: 1-3501@127.0.0.1
CSeq: 1 ACK
Contact: sip:sipp@127.0.0.1:5061;transport=UDP
Max-Forwards: 70
Subject: Performance Test
Content-Length: 0
<------------->
[Feb 18 15:34:46] VERBOSE[3462] chan_sip.c: — (10 headers 0 lines) —
[Feb 18 15:34:46] VERBOSE[3462] chan_sip.c: Really destroying SIP dialog ‘1-3501@127.0.0.1’ Method: ACK

The log messages gives you all the information you need:

[Feb 18 15:34:46] VERBOSE[3462][C-00000001] chan_sip.c: No matching peer for ‘1111’ from ‘127.0.0.1:5061’
[Feb 18 15:34:46] VERBOSE[3462][C-00000001] chan_sip.c: Looking for 2222 in default (domain 127.0.0.1)
[Feb 18 15:34:46] NOTICE[3462][C-00000001] chan_sip.c: Call from ‘’ (127.0.0.1:5061) to extension ‘2222’ rejected because extension not found in context ‘default’.

So you’d need to identify which assumption you’ve made isn’t being met. In this case it would be that the peer is being matched, so now you need to figure out why it isn’t.

Hi jcolp,

I figured out why ast2 tried to lookup 2222 in domain 127.0.0.1.
In the general section of sip.conf file for ast2, I had configured bindaddress=127.0.0.2. But the correct variable is bindaddr, so Asterisk could not recognize this, and would default to 127.0.0.1.
So both my Asterisk instances was running on same IP-address.

Thank you for time and your kind help.

Best regards,
malacho

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