<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:78523703;
        mso-list-type:hybrid;
        mso-list-template-ids:-163695532 68812815 68812825 68812827 68812815 68812825 68812827 68812815 68812825 68812827;}
@list l0:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l1
        {mso-list-id:1631281017;
        mso-list-type:hybrid;
        mso-list-template-ids:-525011192 68812815 68812825 68812827 68812815 68812825 68812827 68812815 68812825 68812827;}
@list l1:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l1:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l1:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l1:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l1:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l1:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l1:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l1:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l1:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=HR link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Hello members,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I'm working with ARI interface (Asterisk 13.9.1, 13.11.2) and trying to make simple routing app with bridging inbound and outbound call together.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Scenario: <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='mso-list:Ignore'>1.<span style='font:7.0pt "Times New Roman"'>       </span></span><![endif]>Inbound call comes via ARI to my app and it isn't answered yet,<o:p></o:p></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='mso-list:Ignore'>2.<span style='font:7.0pt "Times New Roman"'>       </span></span><![endif]>My app finds route for outdial and originates new call to destination,<o:p></o:p></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='mso-list:Ignore'>3.<span style='font:7.0pt "Times New Roman"'>       </span></span><![endif]>Originate result is reflected to inbound call (e.g. if there is no answer on outbound call, hangup with no answer code is sent to inbound call. Or when outbound call is answered, inbound is answered as well, etc...)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Inbound and outbound calls must be bridged ASAP in order not to lose media between them. First, I've tried to make bridge and add channels to bridge after both channels have been answered, but then I realized that there is a gap in media around 200-300 millis, which means that inbound call doesn't hear media from inbound call for first few hundred millis which is not acceptible for me. Then, I have changed app in the way to create bridge and add inbound call into it before outbound call even starts, and add only outbound channel to bridge later to reduce neccessary time for joining bridge as much as possible after both channels are connected. That works and improvement is visible. Lost media is reduced to only approx. 50 millis which is much better.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Now the problem. What I have tried to do when developing second version is to add oubound channel to bridge before it is answered, so after sending 'originate' command. Response from 'originate' gave me a hope that this will actaually work, because events that app gets almost immediately are: ChannelCreated, ..., ChannelStateChange (Dialing), ChannelStateChange (Ringing),... which means there is a channel created, there is channel ID, it is sent to my Stasis app (it must be app is registered for channel's events), remote end is dialed and it is even ringing. But no, when I try to add this channel to bridge, response is quite strange for me: Channel not in Stasis application!<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I'm wondering how it can be that newly created channel from my Stasis app which even gets almost immediately events for it, is not in Stasis application?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Also, some of the events that are coming after 'originate' are also not so clear to me. Below you can see the log:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>16-10-21 14:04:34.218 TRACE | Make call to DAHDI/r1/42999104 from 98765 with early media to channel<o:p></o:p></p><p class=MsoNormal>16-10-21 14:04:34.248 TRACE | Event ChannelCreated - Channel: 1477051663.413<o:p></o:p></p><p class=MsoNormal>16-10-21 14:04:34.258 TRACE | Event DeviceStateChanged - Name: DAHDI/i1/42999104 | State: INUSE<o:p></o:p></p><p class=MsoNormal>16-10-21 14:04:34.268 TRACE | Event ChannelVarset - Channel: 1477051663.413 | Variable: TRANSFERCAPABILITY | Value: SPEECH<o:p></o:p></p><p class=MsoNormal>16-10-21 14:04:34.288 TRACE | Event ChannelDialplan - Channel: 1477051663.413 | DialplanApp: AppDial2<o:p></o:p></p><p class=MsoNormal>16-10-21 14:04:34.298 TRACE | Event ChannelCallerId - Channel: 1477051663.413 | CallerPresentationTxt: Presentation Allowed, Not Screened | CallerPresentation: 0<o:p></o:p></p><p class=MsoNormal>16-10-21 14:04:34.308 TRACE | Event ChannelConnectedLine - Channel: 1477051663.413 | Caller:  (98765) | ConnectedLine:  (98765)<o:p></o:p></p><p class=MsoNormal>16-10-21 14:04:34.318 TRACE | Event DeviceStateChanged - Name: DAHDI/i1/42999104 | State: INUSE<o:p></o:p></p><p class=MsoNormal>16-10-21 14:04:34.338 TRACE | Event ChannelStateChange - Channel: 1477051663.413 | State: Dialing | Name: DAHDI/i1/42999104-3e<o:p></o:p></p><p class=MsoNormal>16-10-21 14:04:34.358 TRACE | Event Dial - Caller: null | Peer:  (98765) | DialStatus:  | DialString: r1/42999104<o:p></o:p></p><p class=MsoNormal>16-10-21 14:04:34.588 TRACE | Event DeviceStateChanged - Name: DAHDI/i1/42999104 | State: RINGING<o:p></o:p></p><p class=MsoNormal>16-10-21 14:04:34.598 TRACE | Event ChannelStateChange - Channel: 1477051663.413 | State: Ringing | Name: DAHDI/i1/42999104-3e<o:p></o:p></p><p class=MsoNormal>16-10-21 14:04:34.618 DEBUG | Enter bridge R-1-30-31 | channel 1477051663.413<o:p></o:p></p><p class=MsoNormal>16-10-21 14:04:34.618 ERROR | Error entering bridge R-1-30-31<o:p></o:p></p><p class=MsoNormal>ch.loway.oss.ari4java.tools.RestException: Channel not in Stasis application<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I have to emphasise that bridge is created before, indial channel was successfully added to it although it is not answered yet.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Events that are odd to me are:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l1 level1 lfo2'><![if !supportLists]><span style='mso-list:Ignore'>1.<span style='font:7.0pt "Times New Roman"'>       </span></span><![endif]>ChannelDialplan – DialplanApp is ' AppDial2' (my ARI app is called differently, I assume this is some native Asterisk app that does the originate work)<o:p></o:p></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l1 level1 lfo2'><![if !supportLists]><span style='mso-list:Ignore'>2.<span style='font:7.0pt "Times New Roman"'>       </span></span><![endif]>StasisStart is not received yet. It will come after destination is answered, so after event: ChannelStateChange (Up). Probably this is the essence of the problem.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>As soon as event ChannelStateChange (Up) comes, app can successfully add outbound channel to bridge, event if it is started before StasisStart event comes. But I would like to add channel to bridge before it is answered, so channels are already bridged in the moment they are both connected.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Can somebody please tell me if this behaviour is intended and fine? Or maybe I have to use different approach to solve the problem?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Also, I have found thread that talks about similar or even the same problem: Expected Early Bridge Behavior (<a href="http://lists.digium.com/pipermail/asterisk-app-dev/2016-March/000769.html">http://lists.digium.com/pipermail/asterisk-app-dev/2016-March/000769.html</a>), but I didn't find answer there.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thank you,<o:p></o:p></p><p class=MsoNormal>Marin Odrljin<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>