[Home]

Summary:ASTERISK-04431: FastAGI / AGI command SET MUSIC ON class not working.
Reporter:Matt King, M.A. Oxon. (kebl0155)Labels:
Date Opened:2005-06-17 12:50:16Date Closed:2011-06-07 14:10:47
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Resources/res_agi
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:Hello,

OK I've set up a musiconhold class called 'matt'.  I know it's working because I can dial the following extension:

exten => 1003,1,Answer
exten => 1003,2,MusicOnHold(matt)
exten => 1003,3,Wait(20)
exten => 1003,4,Hangup

and hear it, with no errors/warnings on the console, which shows the following:

   -- Executing MusicOnHold("SIP/12345-e016", "matt") in new stack
   -- Started music on hold, class 'matt', on SIP/12345-e016

I need to also be able to set it over FastAGI.  I know my AGI connection is working.

I'm sending

SET MUSIC ON matt

and I've also tried

SET MUSIC ON "matt"

In either case I get a message like:

Jun 17 18:47:23 WARNING[23785]: res_musiconhold.c:870 local_ast_moh_start: No class: matt

The music doesn't play.  

Hope this helps,

Matt.
Comments:By: Clod Patry (junky) 2005-06-17 14:39:22

that'S not major.
Can i see real AGI commands in here?
and maybe musiconhold.conf too could be useful.



By: Clod Patry (junky) 2005-06-17 15:45:19

And if u calling FastAGI, are u sure, the other machine has a class named matt?
In simple AGI, everything works fine?

By: Russell Bryant (russell) 2005-06-18 13:41:05

Are you sending a newline after matt or something?

By: Matt King, M.A. Oxon. (kebl0155) 2005-06-19 06:12:30

OK here's musiconhold.conf on the Asterisk server, which definitely has a class called matt, which definitely works (see extensions.conf example above).

;
; Music on hold class definitions
;
[classes]
default=> custom:/var/lib/asterisk/mohmp3,/usr/bin/rawplayer
matt=> custom:/var/lib/asterisk/mohmp3,/usr/bin/rawplayer

We're using the rawplayer trick described on voip-info.org for performance, but the same error occurs using mp3s.  It's nothing to do with that.

Sending

SET MUSIC ON

causes the default class to play correctly, but sending

SET MUSIC ON matt

or even

SET MUSIC ON default

causes the error described.

The other machine isn't running Asterisk, just the FastAGI server.

We're not sending an extra newline after the message.  The FastAGI response from Asterisk is

200 result=0

yet the following error is shown in the Asterisk console and the music doesn't play.

   -- Remote UNIX connection
   -- Executing Goto("SIP/12345-5de9", "q|1") in new stack
   -- Goto (orderlyq,q,1)
   -- Executing Ringing("SIP/12345-5de9", "") in new stack
   -- Executing Wait("SIP/12345-5de9", "2") in new stack
   -- Executing AGI("SIP/12345-5de9", "agi://192.168.0.1") in new stack
Jun 19 12:05:54 WARNING[1168]: res_musiconhold.c:870 local_ast_moh_start: No class: matt

Hope this helps,

Matt.

Follows source code for my AGI server, and logging output.  Full source code for OrderlyCalls (pre-release) is at http://www.orderlyq.com/OrderlyCalls.zip

--------------------
package com.orderlysoftware.orderlycalls.test;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.orderlysoftware.orderlycalls.OrderlyCalls;
import com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection;
import com.orderlysoftware.orderlycalls.asterisk.agi.AGIProcessor;
import com.orderlysoftware.orderlycalls.asterisk.agi.AGIServer;
import com.orderlysoftware.orderlycalls.asterisk.agi.AGISettings;
import com.orderlysoftware.orderlycalls.asterisk.agi.AGISettings.BindSettings;

/**
* @author matt
*
public class MusicTester implements AGIProcessor {
static Logger log=Logger.getLogger("com.orderlysoftware.orderlycalls.text.MusicTester");

public void processCall(AGIConnection call) throws IOException {
// TODO Auto-generated method stub
call.setMusic(true,"matt");
try {
Thread.sleep(20000);
} catch (InterruptedException ie) {

}
}

public static void main(String args[]) {
OrderlyCalls.setLogLevel(Level.FINEST);

AGISettings settings = new AGISettings();
int port=4573;
settings.setProcessorClass(MusicTester.class);
settings.setName("master");
AGISettings.BindSettings bs = settings.new BindSettings();
settings.addBinding(bs);
bs.setAddress(new InetSocketAddress(port));
log.info("Bindings: "+settings.getBindings());

AGIServer server = AGIServer.getInstance(settings,true);

}
}
------------------------------
Relevant code from AGIConnection:

public int setMusic(boolean enable, String music) throws IOException {
String msg = "SET MUSIC ";
if (enable)
msg += "ON";
else
msg += "OFF";
if (music != null)
msg += " " + music;
send(msg);
return getIntResult();
}

private void send(String message) throws IOException {
log.fine("Sending " + message);
pout.println(message);
pout.flush();
}

private int getIntResult() throws IOException {
String result = getResult();
log.fine("Result is " + result);
int spacePos = result.indexOf(" ");
if (spacePos != -1) {
result = result.substring(0, spacePos);
}
return Integer.parseInt(result);
}

private String getResult() throws IOException {
String line = readLine();
//Needs testing
int equalPos = line.indexOf("=");
if (equalPos == -1)
return "-1";
line = line.substring(equalPos + 1);
return line;
}

private String readLine() throws IOException {
String line = in.readLine();
log.fine(line);
if (line == null) {
//Indicates closed connection.
throw new IOException("Socket Closed (Probably Caller HangUp)");
}
if (line.indexOf("510 Invalid or unknown command") != -1) {
log.warning("Invalid command returned - probably spurious!");
return readLine();
}
return line;
}


Logging output:

19-Jun-2005 12:05:18 com.orderlysoftware.orderlycalls.test.MusicTester main
INFO: Bindings: [*:4573]
19-Jun-2005 12:05:18 AGIServer:master run
INFO: Listening on *:4573
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.base.ObjectPool getInstance
FINE: Creating new class com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection run
FINE: Processing Request
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_network: yes
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_request: agi://192.168.0.1
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_channel: SIP/12345-5de9
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_language: en
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_type: SIP
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_uniqueid: 1119179152.0
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_callerid: 12345
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_calleridname: matt
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_callingpres: 0
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_callingani2: 0
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_callington: 0
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_callingtns: 0
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_dnid: 1000
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_rdnis: unknown
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_context: orderlyq
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_extension: q
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_priority: 3
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_enhanced: 0.0
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: agi_accountcode:
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE:
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection send
FINE: Sending SET MUSIC ON matt
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection readLine
FINE: 200 result=0
19-Jun-2005 12:05:51 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection getIntResult
FINE: Result is 0
19-Jun-2005 12:06:11 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection clean
FINE: Cleaned up.
19-Jun-2005 12:06:11 com.orderlysoftware.orderlycalls.asterisk.agi.AGIConnection free
FINE: Freeing AGIConnection

By: Kevin P. Fleming (kpfleming) 2005-06-20 20:46:08

The code path for SET MUSIC is very simple, and I can't see any reason why it would work in a normal diaplan but not via AGI. If you are able to add some debugging statements to res_agi.c and/or res_musiconhold,c, we need to see exactly what the contents of the class name being passed to ast_moh_start() are. If you can't do this, but can provide SSH access at a time when we can work on the machine (not during production, obviously), we can get this figured out.

By: Matt King, M.A. Oxon. (kebl0155) 2005-06-21 10:08:32

Hello,

Unfortunately the machine in question is behind a NAT, so I can't offer remote access.

I will add the debugging statements as described and send you the output.

Many thanks,

Matt.

By: Michael Jerris (mikej) 2005-07-12 19:35:52

Over 3 weeks no response.  Unfortunately we can not address this without the additional information.  I am going to suspend this bug pending additional information, please re-open this bug when you are ready to proceed?