Can a maven build be used to run AGI applications

Hi,

I am new to Asterisk, I could find online help on how to run a agi script in java using fastagi. However our requirement is to run a maven spring boot project on agi. How do we execute such application which listens to fastagi channel.

my example below

pom.xml

<?xml version="1.0" encoding="UTF-8"?>


4.0.0

<groupId>com.netxcell</groupId>
<artifactId>IVR</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>IVR</name>
<description>IVR project for Spring Boot</description>

<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>1.5.2.RELEASE</version>
	<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
	<java.version>1.7</java.version>
</properties>

<dependencies>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-jpa</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-rest</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-web</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-web-services</artifactId>
	</dependency>

	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
		<scope>runtime</scope>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
		<scope>test</scope>
	</dependency>

    <dependency>
        <groupId>org.asteriskjava</groupId>
        <artifactId>asterisk-java</artifactId>
        <version>1.0.0-final</version>
    </dependency>
</dependencies>

<build>
	<plugins>
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
		</plugin>
	</plugins>
</build>

java file

package com.ell;

import org.asteriskjava.fastagi.AgiChannel;
import org.asteriskjava.fastagi.AgiException;
import org.asteriskjava.fastagi.AgiRequest;
import org.asteriskjava.fastagi.BaseAgiScript;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Ivr extends BaseAgiScript{

public static void main(String[] args) {
	SpringApplication.run(Ivr.class, args);
}

@Override
public void service(AgiRequest request, AgiChannel channel)
        throws AgiException{
    streamFile("/var/lib/asterisk/sounds/nxlaudio/sm/16");
    hangup();
}

}

I have followed the standard example available on http://www.jcgonzalez.com/asterisk-handle-calls-with-java-example

I am not sure how to run the same app at commandline loading the application jar.

output on cli is

AGI Tx >> agi_network: yes
AGI Tx >> agi_network_script: hello.agi
<PJSIP/asterisk2-00000071>AGI Tx >> agi_request: AGI://localhost:9001/hello.agi
<PJSIP/asterisk2-00000071>AGI Tx >> agi_channel: PJSIP/asterisk2-00000071
<PJSIP/asterisk2-00000071>AGI Tx >> agi_language: en
<PJSIP/asterisk2-00000071>AGI Tx >> agi_type: PJSIP
<PJSIP/asterisk2-00000071>AGI Tx >> agi_uniqueid: 1490183313.223
<PJSIP/asterisk2-00000071>AGI Tx >> agi_version: 14.2.1
<PJSIP/asterisk2-00000071>AGI Tx >> agi_callerid: 9001
<PJSIP/asterisk2-00000071>AGI Tx >> agi_calleridname: unknown
<PJSIP/asterisk2-00000071>AGI Tx >> agi_callingpres: 0
<PJSIP/asterisk2-00000071>AGI Tx >> agi_callingani2: 0
<PJSIP/asterisk2-00000071>AGI Tx >> agi_callington: 0
<PJSIP/asterisk2-00000071>AGI Tx >> agi_callingtns: 0
<PJSIP/asterisk2-00000071>AGI Tx >> agi_dnid: unknown
<PJSIP/asterisk2-00000071>AGI Tx >> agi_rdnis: unknown
<PJSIP/asterisk2-00000071>AGI Tx >> agi_context: MenuInput1
<PJSIP/asterisk2-00000071>AGI Tx >> agi_extension: 1
<PJSIP/asterisk2-00000071>AGI Tx >> agi_priority: 7
<PJSIP/asterisk2-00000071>AGI Tx >> agi_enhanced: 0.0
<PJSIP/asterisk2-00000071>AGI Tx >> agi_accountcode:
<PJSIP/asterisk2-00000071>AGI Tx >> agi_threadid: -1236014224
<PJSIP/asterisk2-00000071>AGI Tx >> agi_arg_1: ‘ISLAMIC_SUB’
<PJSIP/asterisk2-00000071>AGI Tx >> agi_arg_2: 1
<PJSIP/asterisk2-00000071>AGI Tx >> agi_arg_3: 9001
<PJSIP/asterisk2-00000071>AGI Tx >>
<PJSIP/asterisk2-00000071>AGI Rx << HTTP/1.1 400
<PJSIP/asterisk2-00000071>AGI Tx >> 510 Invalid or unknown command
<PJSIP/asterisk2-00000071>AGI Rx << Transfer-Encoding: chunked
<PJSIP/asterisk2-00000071>AGI Tx >> 510 Invalid or unknown command
[Mar 22 17:19:24] ERROR[28278][C-0000006f]: utils.c:1405 ast_carefulwrite: write() returned error: Connection reset by peer
<PJSIP/asterisk2-00000071>AGI Rx << Date: Wed, 22 Mar 2017 11:49:24 GMT
<PJSIP/asterisk2-00000071>AGI Tx >> 510 Invalid or unknown command
<PJSIP/asterisk2-00000071>AGI Rx << Connection: close
<PJSIP/asterisk2-00000071>AGI Tx >> 510 Invalid or unknown command
<PJSIP/asterisk2-00000071>AGI Rx <<
<PJSIP/asterisk2-00000071>AGI Tx >> 510 Invalid or unknown command
<PJSIP/asterisk2-00000071>AGI Rx << 0
<PJSIP/asterisk2-00000071>AGI Tx >> 510 Invalid or unknown command
<PJSIP/asterisk2-00000071>AGI Rx <<
<PJSIP/asterisk2-00000071>AGI Tx >> 510 Invalid or unknown command
– <PJSIP/asterisk2-00000071>AGI Script AGI://localhost:9001/hello.agi completed, returning 0
<PJSIP/asterisk2-00000071>AGI Tx >> HANGUP
– Executing [1@MenuInput1:8] Wait(“PJSIP/asterisk2-00000071”, “0.5”) in new stack
– Executing [1@lMenuInput1:9] Hangup(“PJSIP/asterisk2-00000071”, “”) in new stack
== Spawn extension MenuInput1, 1, 9) exited non-zero on ‘PJSIP/asterisk2-00000071’

on spring-boot load console

ote: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:421) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:667) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) [tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434) [tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.11.jar!/:8.5.11]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_80]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.11.jar!/:8.5.11]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_80]

extensions.conf

same = n,AGI(AGI://localhost:9001/hello.agi,${PACK},${USER_CHOICE},${CALLNO})

command used to execute spring boot jar

java -jar IVR-0.0.1-SNAPSHOT.jar

Kindly help.

I could now build the application, but this error is seen when an agi request is received

2017-03-23 10:53:13.910 INFO 10139 — [ main] o.asteriskjava.fastagi.DefaultAgiServer : Listening on *:4573.
2017-03-23 10:54:57.147 INFO 10139 — [ main] o.asteriskjava.fastagi.DefaultAgiServer : Thread pool started.
2017-03-23 10:54:57.162 INFO 10139 — [ DaemonPool-1.1] o.a.f.ResourceBundleMappingStrategy : Resource bundle ‘fastagi-mapping’ not found.
2017-03-23 10:54:57.165 ERROR 10139 — [ DaemonPool-1.1] o.a.f.internal.FastAgiConnectionHandler : No script configured for URL ‘agi://localhost:4573/hello.agi’ (script ‘hello.agi’)

extensions.conf

same = n,AGI(agi://localhost:4573/hello.agi,${PACK},${USER_CHOICE},${CALLNO})

fastagi-mapping.properties

hello.agi = com.ell.Ivr
hello2.agi = HelloAgiScript2

Please help