svoboda-jan / asterisk-ari Goto Github PK
View Code? Open in Web Editor NEWRuby client library for the Asterisk REST Interface (ARI).
License: MIT License
Ruby client library for the Asterisk REST Interface (ARI).
License: MIT License
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:
asterisk-ari/lib/ari/client.rb
Lines 31 to 42 in ccb77ad
Unfortunately for sendMessage this does not work correctly because body
parameter is placed inside request.body
asterisk-ari/lib/ari/client.rb
Line 39 in ccb77ad
{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
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.
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
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
Hello,
Any ideas how to manage a timeout ? (if the Asterisk server doesn't answer)
Thanks for the gem by the way
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'
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.