Search code examples
freeswitch

Why FreeSwitch api command does not work in CLI?


From this guide, I know that FreeSwitch (FS) will load modules, each module would provides some commands and all these commands can be accessed from FS_CLI or ESL.

Here is my test:

1/ Show available commands from FS_CLI:

freeswitch@my-pc> show api
name,description,syntax,ikey
...,Shutdown,,mod_commands
acl,Compare an ip to an acl list,<ip> <list_name>,mod_commands
alias,Alias,[add|stickyadd] <alias> <command> | del [<alias>|*],mod_commands
banner,Return the system banner,,mod_commands
bg_system,Execute a system command in the background,<command>,mod_commands
bgapi,Execute an api command in a thread,<command>[ <arg>],mod_commands
.... other commands....

And I don't see api command from above list.

2/ Try to run api command from Inbound socket connection:

➜  ~ telnet localhost 8021
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Content-Type: auth/request

auth ClueCon

Content-Type: command/reply
Reply-Text: +OK accepted

api msleep 2000

Content-Type: api/response
Content-Length: 3

+OK

3/ Try to run api command from FS_CLI:

freeswitch@my-pc> api msleep 2000
-ERR api msleep 2000 Command not found!

Pls, help me to explain why #2 worked but not #3 (afaik FS_CLI utilizes socket under the hood)


Solution

  • Try to remove api in the command it should work.

    freeswitch@ip-172-31-33-109> msleep 2000
    +OK
    

    You need to add api when try to call a command outside of CLI in CLI no need to add api without it's work.