marcelog / elixir_ami

An Elixir AMI client
Apache License 2.0
13 stars 8 forks source link

problem with "No Callers" #1

Closed matteosister closed 8 years ago

matteosister commented 8 years ago

Trying to issue the "queues" command I get:

** (exit) exited in: GenServer.call(:asterisk, {:send, %ElixirAmi.Action{id: "-576460752303423453", keys: %{}, name: "Queues", variables: %{}}}, 5000)
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: ["No Callers"]
            (elixir_ami) lib/elixir_ami/event.ex:35: anonymous fn/2 in ElixirAmi.Event.unserialize/2
            (elixir) lib/enum.ex:1473: Enum."-reduce/3-lists^foldl/2-0-"/3
            (elixir_ami) lib/elixir_ami/connection.ex:244: ElixirAmi.Connection.handle_info/2
            (stdlib) gen_server.erl:615: :gen_server.try_dispatch/4
            (stdlib) gen_server.erl:681: :gen_server.handle_msg/5
            (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

07:56:18.990 [error] GenServer :asterisk terminating
** (MatchError) no match of right hand side value: ["No Callers"]
    (elixir_ami) lib/elixir_ami/event.ex:35: anonymous fn/2 in ElixirAmi.Event.unserialize/2
    (elixir) lib/enum.ex:1473: Enum."-reduce/3-lists^foldl/2-0-"/3
    (elixir_ami) lib/elixir_ami/connection.ex:244: ElixirAmi.Connection.handle_info/2
    (stdlib) gen_server.erl:615: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:681: :gen_server.handle_msg/5
    (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
    (elixir) lib/gen_server.ex:564: GenServer.call/3

the problem is in this line:

[k, v] = for s <- (String.split line, ":", parts: 2), do: String.strip s

the line in this case is:

Members: "
      xxxx (Local/203@from-queue/n from hint:203@ext-local) (ringinuse enabled)\e[0m\e[0m\e[0m (\e[1;32;40mNot in use\e[0m) has taken no calls yet"
      xxxx (Local/201@from-queue/n from hint:201@ext-local) (ringinuse enabled)\e[0m\e[0m\e[0m (\e[1;32;40mNot in use\e[0m) has taken no calls yet"
   No Callers"

We are using asterisk 13.5.0

marcelog commented 8 years ago

Hello!

That reply doesn't seem to respect the AMI protocol: https://wiki.asterisk.org/wiki/display/AST/AMI+Command+Syntax

I'm not sure there's something that can be done about it, this is something that is actually pretty common (Asterisk responding with incompatible replies).

This is also similar to https://github.com/marcelog/PAMI/pull/61

Have you tried using QueueStatus to get the Queue info instead?

matteosister commented 8 years ago

QueueStatus works great! Thanks!