[asterisk-users] RAGI channel_status() never returnes

Hisashi Adachi hadachi at gmail.com
Thu Apr 12 17:26:28 MST 2007


Hi there,

I am new to this ML. Recently I started working on Asterisk 1.4 + RAGI +
Ruby on Rails to create a call history browser.

To record call history, I am trying to capture dialup, answer and hangup
events. To check what status a call is, I use channel_status() that RAGI
provides.

I am having a trouble on this function. In a polling loop that checks
call status, the first call of channel_status() returns -1 that
indicates a failure. Then the second call never returns to caller once
called. Below is a debug log and the code snippet of my app:

debug log:
[2007-04-13 08:42:40] INFO  Dialup
[2007-04-13 08:42:40] INFO  Dialing
[2007-04-13 08:42:40] INFO  Waiting for call to be done
[2007-04-13 08:42:40] INFO  -1
[2007-04-13 08:42:48] INFO  Hangup

code:
require 'ragi/call_handler'
require "thread"

class CallHistoryHandler < RAGI::CallHandler
  def dialup
    logger = WEBrick::Log::new
    logger.info("Dialup")

    hangup = false;

    Thread.start {
      # Keep running until the call is hung up
      while hangup  == false
        # The 1st call returns -1
        # The 2nd call never returns
        status = channel_status()

        # To show the polling loop keeps on running
        logger.info("Waiting for call to be done")

        if status == 4
          logger.info("Ringing")	# Still ringing
        elsif status == 6
          logger.info("Answered")	# Call is answered
        else
          logger.info(status)
        end
      end

      # dial() is done
      logger.info("Call has been hung up")
    }

    logger.info("Dialing")
    dial('IAX2/' + @params['agi_extension'])	# Place a call
    hangup = true;	# Notify the call is hung up.

    logger.info("Hangup")
  end
end

Does anyone have clue about why the 2nd call of channel_status() never
returns?

Best regards,
Hisashi Adachi
hadachi at gmail.com


More information about the asterisk-users mailing list