Trying use agi to listen asterisk.
But after startup method is running, my application is freezing. There is no error appears...
My spring bean:
@Bean(name = "agi")
public DefaultAgiServer getAsteriskAgi() throws Exception {
DefaultAgiServer agiServer = new DefaultAgiServer();
agiServer.startup();
return agiServer;
}
My mapping
public class AsteriskAgi extends BaseAgiScript{
@Override
public void service(AgiRequest agiRequest, AgiChannel agiChannel) throws AgiException {
// Answer the channel...
answer();
// ...say hello...
streamFile("welcome");
streamFile("tt-monkeys");
// ...and hangup.
hangup();
}
}
my properties file
fastagi-mapping.properties
located in resources folder
Why is this happening?
UPD Last two console output:
2018-05-21 15:19:53 DEBUG DefaultAgiServer:81 - Using channelFactory org.asteriskjava.fastagi.internal.DefaultAgiChannelFactory
2018-05-21 15:19:53 INFO DefaultAgiServer:315 - Listening on *:4573.
Tomcat hang on startup because the AGI server is blocking it and waits for incoming AGI data from socket connection link. To solve this you should wrap your AgiServer in a separate thread so that it runs in the background or use AgiServerThread.
In result my asterisk agi configuration looks like this:
@Bean
public AgiServerThread agiServerThread(){
AgiServerThread agiServerThread = new AgiServerThread(getDefaultAgiServer());
agiServerThread.startup();
return agiServerThread;
}
@Bean
public DefaultAgiServer getDefaultAgiServer(){
return new DefaultAgiServer(getAsteriskAgiScript());
}
@Bean
public AgiScript getAsteriskAgiScript(){
return new AsteriskAgi();
}