Author Message
MarcusHuang
Joined: Feb 25, 2014
Messages: 157
Offline
Hi All,

Can someone help me understand why my call would disconnect when answered? I say hello, so it should be a live voice. This is basically copied from the example, but getting the number to dial from a database call through JSP?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ccxml PUBLIC "-//W3C//DTD CCXML 1.0//EN" "http://www.w3.org/TR/ccxml/ccxml.dtd">
<ccxml version="1.0" xmlns="http://www.w3.org/2002/09/ccxml">
<%@ page import="java.util.*"%>
<%@ page import="java.net.*"%>
<%@ page import="java.sql.*"%>
<%@ page contentType="application/ccxml+xml"%>
<%

/* do not want jsp content cached */
response.setHeader("Cache-Control", "no-store");
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", "1");

/*
* grab the host and save the app server host port for use later
* this makes the application urls "relative" to request so when
* we deploy this application we do not have to change the urls.
*/
//URL url = new URL (request.getRequestURL().toString());
//String host = url.getHost();
//String port = Integer.toString(url.getPort());
//String locationExt = "http://" + host + ":" + port;
//String locationLocal = "http://" + host + ":" + port + "/RouteToPhoneNumber";


//Setting Up JDBC Connection for MS Sql
String callerId = "8001234567";
String toUri = "";
String url = "jdbc:sqlserver://sqldbserver01:1433;databaseName=Database";
String userName = "user";
String passWord = "pass";
String sql = "SELECT OnCallNumber FROM dev.CompanyOnCall WHERE exits=?";
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection(url,userName,passWord);
if(con!=null){
System.out.println("Database Connected");
}
PreparedStatement statement = con.prepareStatement(sql);
statement.setString(1, "OnCall");
ResultSet resultSet = statement.executeQuery();

if(resultSet.next()){
toUri=resultSet.getString("OnCallNumber");
}

System.out.println("To URI = " + toUri);
resultSet.close();
statement.close();
con.close();
%>


<!-- convert an object to a string by iterating through it structure -->
<script>
function objectToString( obj ) {
var result = " [\n";
result += extractprops( "", obj);
result += " ]";
return result;
}

function extractprops ( parent, obj ) {
var prop, name, result = "";
var count = 1;
if ( typeof ( obj ) == "object" ) {
for ( prop in obj ) {
name = parent + prop;
if ( typeof ( obj [ prop ] ) == "object" ) {
result += extractprops( name+".", obj [ prop ] );
} else {
result += " " + name + ":" + obj [ prop ] + "\n";
}
count = count + 1;
}
} else {
if (obj == undefined ) {
result += "undefined";
} else {
result += obj;
}
}
return result;
}
</script>

<var name="in_connectionid"/> <!-- The connectionid of the incoming call. -->
<var name="out_connectionid"/> <!-- The connectionid of the outgoing call. -->
<var name="dialogid"/> <!-- The id of the dialog we will run. -->
<var name="to_Uri" expr="'<%=toUri%>'+'@Company.com'"/>
<var name="caller_Id" expr="'<%=callerId%>'"/>

<!-- Initialize the state for this page -->
<var name="state" expr="'init'"/>

<!-- Possible states:
init - The initialized state, accept the call.
calling - Placing an outbound call
-->

<!-- Event processor -->
<eventprocessor statevariable="state">

<!-- STATE: init -->

<!-- New call is coming in, accept it blindly -->
<transition event="connection.alerting" state="init" >
<log expr="'-- ' + event$.name +' -- [' + state +']'"/>
<log expr="' eventdata... \n' + objectToString(event$)"/>
<assign name="in_connectionid" expr="event$.connectionid"/>
<accept/>
</transition>

<!-- Create a new call dialing a hardcoded # -->
<transition event="connection.connected" state="init" >
<log expr="'-- ' + event$.name +' -- [' + state +']'"/>
<log expr="' eventdata... \n' + objectToString(event$)"/>
<assign name="state" expr="'calling'"/>

<!--
enable call classification the call classification
will arrive in a connection.signal event.
-->
<var name="hints" expr="new Object();"/>
<assign name="hints.enable_call_classification" expr= "true"/>
<assign name="hints.call_classification_timeout" expr= "20000"/>

<createcall dest="'sip:'+to_Uri"
connectionid="out_connectionid"
timeout="30000"
callerid="caller_Id"
hints="hints" />
</transition>

<transition event="connection.connected" state="calling" >
<log expr="'-- ' + event$.name +' -- [' + state +']'"/>
<log expr="' eventdata... \n' + objectToString(event$)"/>
<log expr="'connected to caller, join the call!'"/>
<assign name="state" expr="'connected'"/>
<join id1="in_connectionid" id2="out_connectionid" duplex="'full'"/>
</transition>

<transition event="connection.signal" >
<log expr="'-- ' + event$.name +' -- [' + state +']'"/>
<log expr="' eventdata... \n' + objectToString(event$)"/>
<if cond="event$.connectionid == out_connectionid">
<if cond="event$.info.callprogress != undefined">
<if cond="event$.info.callprogress != 'live_voice'">
<log expr="' *** Oops no one there\n'"/>
<exit/>
<else/>
<log expr="' *** Got a live one\n'"/>
</if>
<else/>
<log expr="' *** No call progress in this connection.signal\n'"/>
</if>
<else/>
<log expr="' *** Not the out connection\n'"/>
</if>
</transition>

<transition event="connection.failed" state="calling" >
<log expr="'-- ' + event$.name +' -- [' + state +']'"/>
<log expr="' eventdata... \n' + objectToString(event$)"/>
<log expr="'failed to connect to caller'"/>
<exit expr="'Call Failed'"/>
</transition>

<transition event="connection.disconnected" state="">
<log expr="'-- ' + event$.name +' -- [' + state +']'"/>
<log expr="' eventdata... \n' + objectToString(event$)"/>
<if cond="event$.connectionid == in_connectionid">
<exit expr="'Caller Hungup'"/>
<else/>
<exit expr="'Called Number Hungup'"/>
</if>
</transition>

<!-- STATE: ANYSTATE. Catch all, aids in debugging and to see the missed events -->
<transition event="ccxml.exit" >
<log expr="'-- ' + event$.name +' -- [' + state +']'"/>
<log expr="' eventdata... \n' + objectToString(event$)"/>
</transition>

<transition event="ccxml.kill" >
<log expr="'-- ' + event$.name +' -- [' + state +']'"/>
<log expr="' eventdata... \n' + objectToString(event$)"/>
</transition>

<transition event="" >
<log expr="'-- missed ' + event$.name +' -- [' + state +']'"/>
<log expr="' eventdata... \n' + objectToString(event$)"/>
</transition>

</eventprocessor>
</ccxml>
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
The ccxml log on the browser/mpp side should be able to tell you why the call gets disconnected.
MarcusHuang
Joined: Feb 25, 2014
Messages: 157
Offline
WilsonYu wrote:The ccxml log on the browser/mpp side should be able to tell you why the call gets disconnected.


I think i see the issue, but i got most of this code from the example. It seems the info.callprogress = start_of_voice, but CCXML is looking for live_voice. Do i need to update ccxml to look for start_of_voice instead?


Data from ccxml log

eventid:1308628586
eventsource:avayampp05-2022076151008-22
eventsourcetype:AvayaVoicePortal
info.callID:avayampp05-SM8-11-2022076151008
info.callprogress:start_of_voice
info.callprogresstime:3250
name:connection.signal
protocol:sip


CCXML code
<if cond="event$.connectionid == out_connectionid">
<if cond="event$.info.callprogress != undefined">
<if cond="event$.info.callprogress != 'live_voice'">
<log expr="' *** Oops no one there\n'"/>
<exit/>
<else/>
<log expr="' *** Got a live one\n'"/>
</if>
<else/>
<log expr="' *** No call progress in this connection.signal\n'"/>
</if>
<else/>
<log expr="' *** Not the out connection\n'"/>
</if>
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
I am not sure. You have to verify with the platform documentation.
JohnBiggs
Joined: Jun 20, 2005
Messages: 1139
Location: Rural, Virginia
Offline
Another possibility I believe if the call is disconnecting immediately upon answer may be that no compatible codecs were found to support the media connection. It is not clear from this thread how long the call is lasting.
Go to:   
Mobile view