Giter Club home page Giter Club logo

asterisk-ari's People

Contributors

benlangfeld avatar svoboda-jan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asterisk-ari's Issues

Wrong request on sendMessage

According to the following link:
https://wiki.asterisk.org/wiki/display/AST/Asterisk+16+Endpoints+REST+API#Asterisk16EndpointsRESTAPI-sendMessage
when performing a sendMessage the body parameter should be encoded inside the query string and not into request body.

Looking into client.rb this is how the requests are made:

%w{ get put post delete }.each do |http_method|
method_klass = Net::HTTP.const_get http_method.to_s.capitalize
define_method http_method do |path, params = {}|
request_body = params.delete(:body)
params.merge!({ api_key: @options[:api_key], app: @options[:app] })
query_string = URI.encode_www_form params
request_path = "#{@uri.path}#{path}?#{query_string}"
request = method_klass.new request_path, HTTP_HEADERS
request.body = request_body.is_a?(Hash) ? MultiJson.dump(request_body) : request_body
send_request request
end
end

Unfortunately for sendMessage this does not work correctly because body parameter is placed inside request.body

request.body = request_body.is_a?(Hash) ? MultiJson.dump(request_body) : request_body

but Asterisk strips out the body content which is different from {variables: ...}.

Here's a possible solution:

    %w{ get put post delete }.each do |http_method|
      method_klass = Net::HTTP.const_get http_method.to_s.capitalize
      define_method http_method do |path, params = {}|
        http_body = params.delete(:http_body)
        params.merge!({ api_key: @options[:api_key], app: @options[:app] })
        query_string = URI.encode_www_form params
        request_path = "#{@uri.path}#{path}?#{query_string}"
        request = method_klass.new request_path, HTTP_HEADERS
        request.body = http_body.is_a?(Hash) ? MultiJson.dump(http_body) : http_body
        send_request request
      end
    end

We're using :http_body parameter to specify request body, which should prevent this type of conflicts.

Is there any possibility that you will fix this issue?

Best regards,
@FarhanGazi

@serioja90

Playing media in asterisk

Hello,

Could you please help me to play my own audio file after call start?
Or Maybe asterisk can synthesis text after /channels/:id/play?media='My awesome text' call.

How can I see this functionality:

e.channel.on :channel_dtmf_received { |e| e.channel.play(media: "hello world") }

Any help would be awesome.

[question] How should one reconnect?

My server is running behind a NAT that appears to be causing a disconnect after N minutes of inactivity.

I thought it might be trivial to just reconnect on websocket error, like so:

client.on :websocket_error do |err|
  client.connect_websocket
end

But this doesn't seem to work. As far as I can tell, if I reconnect, the old listeners are deleted, which is undesirable.

Is there a recommended strategy to reconnect? If not, can you point me in the direction on what to change to be able to reconnect while keeping the already defined callbacks?

Regards

cannot load such file

Hello,

I installed ruby using rvm, tried to create sample application, but got error:
`require': cannot load such file -- asterisk-ari-client (LoadError)

Gem is installed.
Tried on ruby 1.9.3, 2.0.0, 2.2.1

Thanks in advice

Timeout

Hello,

Any ideas how to manage a timeout ? (if the Asterisk server doesn't answer)

Thanks for the gem by the way

Ari.client.sounds.list results in NameError

model.rb seems to get confused about having the parameters for sounds in an options object.

?> Ari.client.sounds.list
NameError: `@{"language"=>"en", "format"=>"gsm"}' is not allowed as an instance variable name
    from /usr/local/bundle/gems/asterisk-ari-client-0.0.7/lib/ari/model.rb:20:in `instance_variable_set'
    from /usr/local/bundle/gems/asterisk-ari-client-0.0.7/lib/ari/model.rb:20:in `block in attributes='
    from /usr/local/bundle/gems/asterisk-ari-client-0.0.7/lib/ari/model.rb:14:in `each'
    from /usr/local/bundle/gems/asterisk-ari-client-0.0.7/lib/ari/model.rb:14:in `attributes='
    from /usr/local/bundle/gems/asterisk-ari-client-0.0.7/lib/ari/model.rb:9:in `initialize'
    from /usr/local/bundle/gems/asterisk-ari-client-0.0.7/lib/ari/resources/sound.rb:18:in `new'
    from /usr/local/bundle/gems/asterisk-ari-client-0.0.7/lib/ari/resources/sound.rb:18:in `formats='
    from /usr/local/bundle/gems/asterisk-ari-client-0.0.7/lib/ari/model.rb:18:in `block in attributes='
    from /usr/local/bundle/gems/asterisk-ari-client-0.0.7/lib/ari/model.rb:14:in `each'
    from /usr/local/bundle/gems/asterisk-ari-client-0.0.7/lib/ari/model.rb:14:in `attributes='
    from /usr/local/bundle/gems/asterisk-ari-client-0.0.7/lib/ari/model.rb:9:in `initialize'
    from /usr/local/bundle/gems/asterisk-ari-client-0.0.7/lib/ari/resources/sound.rb:35:in `new'
    from /usr/local/bundle/gems/asterisk-ari-client-0.0.7/lib/ari/resources/sound.rb:35:in `block in list'
    from /usr/local/bundle/gems/asterisk-ari-client-0.0.7/lib/ari/resources/sound.rb:35:in `map'
    from /usr/local/bundle/gems/asterisk-ari-client-0.0.7/lib/ari/resources/sound.rb:35:in `list'
    from /usr/local/bundle/gems/asterisk-ari-client-0.0.7/lib/ari/list_resource.rb:16:in `method_missing'

originate always pass 'app' as argument to the asterisk

Hi, I am trying to originate into asterisk dialplan using following command:

Ari::Channel.originate client:  $client,
                                endpoint:  'SIP/test-900',
                                callerid:  'TEST',
                                context:   'queues',
                                extension: 'enter',
                                priority:  1,
                                formats:   'g722,slin,gsm'

I'm getting following with ngrep:

 T +0.001207 172.28.0.6:46736 -> xxxxxx:8088 [AP]
POST /ari/channels?client=%23%3CAri%3A%3AClient%3A0x00005578a62e3c08%3E&endpoint=SIP%2Ftest-900&callerid=TEST&context=queues&extension=enter&priority=1&
formats=g722%2Cslin%2Cgsm&api_key=xxxxxx
fbce4&app=test-app HTTP/1.1.
User-Agent: asterisk-ari-client/0.0.8 ruby/2.5.2.

and if I originate with curl:

T +0.010310 172.28.0.6:46876 -> xxxxxxx:8088 [AP]
POST /ari/channels?endpoint=SIP/test-900&formats=g722&&context=queues&extension=enter&priority=1 HTTP/1.1.
User-Agent: curl/7.61.1.

I think, issue because of this line and it's global for anything where app is optional argument:

https://github.com/svoboda-jan/asterisk-ari/blob/master/lib/ari/client.rb#L35

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.