AsterNET icon indicating copy to clipboard operation
AsterNET copied to clipboard

Reload asterisk after saving extenstion into the asterisk database.

Open manika880 opened this issue 8 years ago • 3 comments

I am developing a web application using ASP.NET MVC. I wrote add functionality in my application to add extension details into asterisk database using asterisk realtime database configuration. But after saving extension details to asterisk database, it needs reload. So how can I reload remotely located asterisk server from my application? For example: we can use asterisk -rx "reload" shell command. I wrote following code to achieve same functionality from my code:

    private static ManagerConnection manager;
    const int ASTERISK_PORT = 5038;
    const string ASTERISK_HOST = "192.168.13.36";
    const string ASTERISK_LOGINNAME = "admin";
    const string ASTERISK_LOGINPWD = "amp111";
    public static void ApplyConfigOnAsterisk() {
        manager = new ManagerConnection(ASTERISK_HOST, ASTERISK_PORT, ASTERISK_LOGINNAME, ASTERISK_LOGINPWD);
        
        try
        {
            manager.Login();
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error connect\n" + ex.Message);
            manager.Logoff();
        }
        {
            Console.WriteLine("\nUpdateConfig action");
            UpdateConfigAction config = new UpdateConfigAction("asterisk.conf", "asterisk.conf", true);
            ManagerResponse response = manager.SendAction(config);
        }
    }

But this code is not working as needed.

manika880 avatar Jun 23 '17 10:06 manika880

When you say not working, are you getting an error or is it simply nothing is happening.

Supplying log output from the console would be helpful, or copies of any exceptions thrown.

Cheers

skrusty avatar Aug 29 '17 11:08 skrusty

Could you maybe be looking for the Reload action? It looks like it isn't implemented in AsterNET right now.

See: https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+ManagerAction_Reload

Deantwo avatar Jul 17 '18 13:07 Deantwo

You can try:

CommandAction commandAction = new CommandAction("core reload");
CommandResponse commandResponse = (CommandResponse)_ami.SendAction(commandAction, 0);
return commandResponse.ToString();

Not sure it will work, but maybe.

If nothing else, the Reload action shouldn't be hard to implement.

Deantwo avatar Jul 17 '18 13:07 Deantwo