ruby_fs -- setup

26 views
Skip to first unread message

John Burke

unread,
Jun 27, 2017, 4:46:26 PM6/27/17
to Adhearsion
Hello!

I've got some basic questions around the ruby_fs gem.  I was looking around for an example setup & command call from Adhearsion to FS.  I've got it setup such that I can see the authentication from FS and Adhearsion.  But once I issue the 'stream.run' command adhearsion just sits there and spins and never reaches the FS command.  I've attached the authentication sequence from an ngrep command on the box running FS, I attached the Adhearsion code, and I attached the Adhearsion logs.

Any help would be greatly appreciated.  Do I have some configuration setup wrong in FS, or am I calling the commands wrong in Adhearsion.


Authentication:

####
Content-Type: auth/request


##
auth ClueCon


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


#
event json ALL


#
Content-Type: command/reply
Reply-Text: +OK event listener enabled json


##
Content-Length: 975
Content-Type: text/event-json



Ruby Code:

logger.info "step #0 -- log"

stream = RubyFS::Stream.new '192.168.20.32', 8021, 'ClueCon', lambda{ |e| p e }

logger.info
"step #1 -- log"

stream.run

logger.info
"step #2 -- log" --------------- (DOESN'T EVER MAKE IT TO THIS STATEMENT) --------------------

response = stream.api 'Originate sofia/internal/10...@192.168.28.133'



Adhearsion Logs:
[2017-06-27 15:41:35.961] INFO  Adhearsion::Call: 030791ec-5b79-11e7...@192.168.20.32: step #0 -- log

[2017-06-27 15:41:35.963] INFO  Adhearsion::Call: 030791ec-5b79-11e7...@192.168.20.32: step #1 -- log

#<RubyFS::Stream::Connected:0x000000036088f0>
[2017-06-27 15:41:35.964] DEBUG RubyFS::Stream: Starting up...

#<RubyFS::Event:0x0000000304e568 @headers={:content_length=>"1072", :content_type=>"text/event-json"}, @content={:event_subclass=>"sofia::register_attempt", :event_name=>"CUSTOM", :core_uuid=>"ac9ef3cc-5b69-11e7-aad9-9b03c205b85f", :freeswitch_hostname=>"wahoo-freeswitch", :freeswitch_switchname=>"wahoo-freeswitch", :freeswitch_ipv4=>"192.168.20.32", :freeswitch_ipv6=>"fe80::cc76:8ff:fee1:11e7", :event_date_local=>"2017-06-27 15:41:44", :event_date_gmt=>"Tue, 27 Jun 2017 20:41:44 GMT", :event_date_timestamp=>"1498596104325336", :event_calling_file=>"sofia_reg.c", :event_calling_function=>"sofia_reg_handle_register_token", :event_calling_line_number=>"1556", :event_sequence=>"3255", :profile_name=>"internal", :from_user=>"1011", :from_host=>"192.168.20.32", :contact=>"\"Kowalski\" <sip:10...@192.168.28.133:5060;transport=udp;fs_nat=yes;fs_path=sip%3A1011%40192.168.28.133%3A5060%3Btransport%3Dudp>", :call_id=>"095af75952d4546c", :rpid=>"unknown", :status=>"Registered(UDP-NAT)", :expires=>"30", :to_user=>"1011", :to_host=>"192.168.20.32", :network_ip=>"192.168.28.133", :network_port=>"5060", :username=>"1011", :realm=>"192.168.20.32", :user_agent=>"Aastra 6863i/3.3.1.7034", :auth_result=>"RENEWED"}>

#<RubyFS::Event:0x00000003016820 @headers={:content_length=>"1087", :content_type=>"text/event-json"}, @content={:event_subclass=>"sofia::register", :event_name=>"CUSTOM", :core_uuid=>"ac9ef3cc-5b69-11e7-aad9-9b03c205b85f", :freeswitch_hostname=>"wahoo-freeswitch", :freeswitch_switchname=>"wahoo-freeswitch", :freeswitch_ipv4=>"192.168.20.32", :freeswitch_ipv6=>"fe80::cc76:8ff:fee1:11e7", :event_date_local=>"2017-06-27 15:41:44", :event_date_gmt=>"Tue, 27 Jun 2017 20:41:44 GMT", :event_date_timestamp=>"1498596104325336", :event_calling_file=>"sofia_reg.c", :event_calling_function=>"sofia_reg_handle_register_token", :event_calling_line_number=>"2005", :event_sequence=>"3256", :profile_name=>"internal", :from_user=>"1011", :from_host=>"192.168.20.32", :presence_hosts=>"192.168.20.32,192.168.20.32", :contact=>"\"Kowalski\" <sip:10...@192.168.28.133:5060;transport=udp;fs_nat=yes;fs_path=sip%3A1011%40192.168.28.133%3A5060%3Btransport%3Dudp>", :call_id=>"095af75952d4546c", :rpid=>"unknown", :status=>"Registered(UDP-NAT)", :expires=>"30", :to_user=>"1011", :to_host=>"192.168.20.32", :network_ip=>"192.168.28.133", :network_port=>"5060", :username=>"1011", :realm=>"192.168.20.32", :user_agent=>"Aastra 6863i/3.3.1.7034"}>
#<RubyFS::Event:0x00000002fcf3d0 @headers={:content_length=>"972", :content_type=>"text/event-json"}, @content={:event_name=>"HEARTBEAT", :core_uuid=>"ac9ef3cc-5b69-11e7-aad9-9b03c205b85f", :freeswitch_hostname=>"wahoo-freeswitch", :freeswitch_switchname=>"wahoo-freeswitch", :freeswitch_ipv4=>"192.168.20.32", :freeswitch_ipv6=>"fe80::cc76:8ff:fee1:11e7", :event_date_local=>"2017-06-27 15:41:48", :event_date_gmt=>"Tue, 27 Jun 2017 20:41:48 GMT", :event_date_timestamp=>"1498596108425325", :event_calling_file=>"switch_core.c", :event_calling_function=>"send_heartbeat", :event_calling_line_number=>"74", :event_sequence=>"3257", :event_info=>"System Ready", :up_time=>"0 years, 0 days, 1 hour, 50 minutes, 0 seconds, 47 milliseconds, 416 microseconds", :freeswitch_version=>"1.6.18+git~20170622T002945Z~373d78f8b2~64bit", :uptime_msec=>"6600047", :session_count=>"1", :max_sessions=>"1000", :session_per_sec=>"30", :session_per_sec_last=>"0", :session_per_sec_max=>"2", :session_per_sec_fivemin=>"1", :session_since_startup=>"19", :session_peak_max=>"2", :session_peak_fivemin=>"1", :idle_cpu=>"99.933333"}>

#<RubyFS::Event:0x00000002f90f90 @headers={:content_length=>"611", :content_type=>"text/event-json"}, @content={:event_name=>"RE_SCHEDULE", :core_uuid=>"ac9ef3cc-5b69-11e7-aad9-9b03c205b85f", :freeswitch_hostname=>"wahoo-freeswitch", :freeswitch_switchname=>"wahoo-freeswitch", :freeswitch_ipv4=>"192.168.20.32", :freeswitch_ipv6=>"fe80::cc76:8ff:fee1:11e7", :event_date_local=>"2017-06-27 15:41:48", :event_date_gmt=>"Tue, 27 Jun 2017 20:41:48 GMT", :event_date_timestamp=>"1498596108425325", :event_calling_file=>"switch_scheduler.c", :event_calling_function=>"switch_scheduler_execute", :event_calling_line_number=>"71", :event_sequence=>"3258", :task_id=>"1", :task_desc=>"heartbeat", :task_group=>"core", :task_runtime=>"1498596128"}>

#<RubyFS::Event:0x00000002f7c270 @headers={:content_length=>"610", :content_type=>"text/event-json"}, @content={:event_name=>"RE_SCHEDULE", :core_uuid=>"ac9ef3cc-5b69-11e7-aad9-9b03c205b85f", :freeswitch_hostname=>"wahoo-freeswitch", :freeswitch_switchname=>"wahoo-freeswitch", :freeswitch_ipv4=>"192.168.20.32", :freeswitch_ipv6=>"fe80::cc76:8ff:fee1:11e7", :event_date_local=>"2017-06-27 15:41:48", :event_date_gmt=>"Tue, 27 Jun 2017 20:41:48 GMT", :event_date_timestamp=>"1498596108425325", :event_calling_file=>"switch_scheduler.c", :event_calling_function=>"switch_scheduler_execute", :event_calling_line_number=>"71", :event_sequence=>"3259", :task_id=>"2", :task_desc=>"check_ip", :task_group=>"core", :task_runtime=>"1498596168"}>

#<RubyFS::Event:0x00000002f34718 @headers={:content_length=>"1072", :content_type=>"text/event-json"}, @content={:event_subclass=>"sofia::register_attempt", :event_name=>"CUSTOM", :core_uuid=>"ac9ef3cc-5b69-11e7-aad9-9b03c205b85f", :freeswitch_hostname=>"wahoo-freeswitch", :freeswitch_switchname=>"wahoo-freeswitch", :freeswitch_ipv4=>"192.168.20.32", :freeswitch_ipv6=>"fe80::cc76:8ff:fee1:11e7", :event_date_local=>"2017-06-27 15:41:59", :event_date_gmt=>"Tue, 27 Jun 2017 20:41:59 GMT", :event_date_timestamp=>"1498596119385344", :event_calling_file=>"sofia_reg.c", :event_calling_function=>"sofia_reg_handle_register_token", :event_calling_line_number=>"1556", :event_sequence=>"3261", :profile_name=>"internal", :from_user=>"1011", :from_host=>"192.168.20.32", :contact=>"\"Kowalski\" <sip:10...@192.168.28.133:5060;transport=udp;fs_nat=yes;fs_path=sip%3A1011%40192.168.28.133%3A5060%3Btransport%3Dudp>", :call_id=>"095af75952d4546c", :rpid=>"unknown", :status=>"Registered(UDP-NAT)", :expires=>"30", :to_user=>"1011", :to_host=>"192.168.20.32", :network_ip=>"192.168.28.133", :network_port=>"5060", :username=>"1011", :realm=>"192.168.20.32", :user_agent=>"Aastra 6863i/3.3.1.7034", :auth_result=>"RENEWED"}>

. . . . JUST KEEPS GOING


Thanks,
John

Luca Pradovera

unread,
Jun 27, 2017, 5:15:12 PM6/27/17
to adhea...@googlegroups.com
Hello,
try this:

```
require 'celluloid'
require 'ruby_fs'

fs_stream_supervisor = RubyFS::Stream.supervise '127.0.0.1', 8021, 'ClueCon', lambda { |e| logger.info e.inspect }
fs_stream = fs_stream_supervisor.actors.first
stream.api 'Originate sofia/internal/10...@192.168.28.133'
```

Let me know how it goes!
Luca


[2017-06-27 15:41:35.961] INFO  Adhearsion::Call: 030791ec-5b79-11e7-ab54-9b03c2...@192.168.20.32: step #0 -- log

[2017-06-27 15:41:35.963] INFO  Adhearsion::Call: 030791ec-5b79-11e7-ab54-9b03c2...@192.168.20.32: step #1 -- log

#<RubyFS::Stream::Connected:0x000000036088f0>
[2017-06-27 15:41:35.964] DEBUG RubyFS::Stream: Starting up...

#<RubyFS::Event:0x0000000304e568 @headers={:content_length=>"1072", :content_type=>"text/event-json"}, @content={:event_subclass=>"sofia::register_attempt", :event_name=>"CUSTOM", :core_uuid=>"ac9ef3cc-5b69-11e7-aad9-9b03c205b85f", :freeswitch_hostname=>"wahoo-freeswitch", :freeswitch_switchname=>"wahoo-freeswitch", :freeswitch_ipv4=>"192.168.20.32", :freeswitch_ipv6=>"fe80::cc76:8ff:fee1:11e7", :event_date_local=>"2017-06-27 15:41:44", :event_date_gmt=>"Tue, 27 Jun 2017 20:41:44 GMT", :event_date_timestamp=>"1498596104325336", :event_calling_file=>"sofia_reg.c", :event_calling_function=>"sofia_reg_handle_register_token", :event_calling_line_number=>"1556", :event_sequence=>"3255", :profile_name=>"internal", :from_user=>"1011", :from_host=>"192.168.20.32", :contact=>"\"Kowalski\" <sip:10...@192.168.28.133:5060;transport=udp;fs_nat=yes;fs_path=sip%3A1011%40192.168.28.133%3A5060%3Btransport%3Dudp>", :call_id=>"095af75952d4546c", :rpid=>"unknown", :status=>"Registered(UDP-NAT)", :expires=>"30", :to_user=>"1011", :to_host=>"192.168.20.32", :network_ip=>"192.168.28.133", :network_port=>"5060", :username=>"1011", :realm=>"192.168.20.32", :user_agent=>"Aastra 6863i/3.3.1.7034", :auth_result=>"RENEWED"}>

#<RubyFS::Event:0x00000003016820 @headers={:content_length=>"1087", :content_type=>"text/event-json"}, @content={:event_subclass=>"sofia::register", :event_name=>"CUSTOM", :core_uuid=>"ac9ef3cc-5b69-11e7-aad9-9b03c205b85f", :freeswitch_hostname=>"wahoo-freeswitch", :freeswitch_switchname=>"wahoo-freeswitch", :freeswitch_ipv4=>"192.168.20.32", :freeswitch_ipv6=>"fe80::cc76:8ff:fee1:11e7", :event_date_local=>"2017-06-27 15:41:44", :event_date_gmt=>"Tue, 27 Jun 2017 20:41:44 GMT", :event_date_timestamp=>"1498596104325336", :event_calling_file=>"sofia_reg.c", :event_calling_function=>"sofia_reg_handle_register_token", :event_calling_line_number=>"2005", :event_sequence=>"3256", :profile_name=>"internal", :from_user=>"1011", :from_host=>"192.168.20.32", :presence_hosts=>"192.168.20.32,192.168.20.32", :contact=>"\"Kowalski\" <sip:10...@192.168.28.133:5060;transport=udp;fs_nat=yes;fs_path=sip%3A1011%40192.168.28.133%3A5060%3Btransport%3Dudp>", :call_id=>"095af75952d4546c", :rpid=>"unknown", :status=>"Registered(UDP-NAT)", :expires=>"30", :to_user=>"1011", :to_host=>"192.168.20.32", :network_ip=>"192.168.28.133", :network_port=>"5060", :username=>"1011", :realm=>"192.168.20.32", :user_agent=>"Aastra 6863i/3.3.1.7034"}>
#<RubyFS::Event:0x00000002fcf3d0 @headers={:content_length=>"972", :content_type=>"text/event-json"}, @content={:event_name=>"HEARTBEAT", :core_uuid=>"ac9ef3cc-5b69-11e7-aad9-9b03c205b85f", :freeswitch_hostname=>"wahoo-freeswitch", :freeswitch_switchname=>"wahoo-freeswitch", :freeswitch_ipv4=>"192.168.20.32", :freeswitch_ipv6=>"fe80::cc76:8ff:fee1:11e7", :event_date_local=>"2017-06-27 15:41:48", :event_date_gmt=>"Tue, 27 Jun 2017 20:41:48 GMT", :event_date_timestamp=>"1498596108425325", :event_calling_file=>"switch_core.c", :event_calling_function=>"send_heartbeat", :event_calling_line_number=>"74", :event_sequence=>"3257", :event_info=>"System Ready", :up_time=>"0 years, 0 days, 1 hour, 50 minutes, 0 seconds, 47 milliseconds, 416 microseconds", :freeswitch_version=>"1.6.18+git~20170622T002945Z~373d78f8b2~64bit", :uptime_msec=>"6600047", :session_count=>"1", :max_sessions=>"1000", :session_per_sec=>"30", :session_per_sec_last=>"0", :session_per_sec_max=>"2", :session_per_sec_fivemin=>"1", :session_since_startup=>"19", :session_peak_max=>"2", :session_peak_fivemin=>"1", :idle_cpu=>"99.933333"}>

#<RubyFS::Event:0x00000002f90f90 @headers={:content_length=>"611", :content_type=>"text/event-json"}, @content={:event_name=>"RE_SCHEDULE", :core_uuid=>"ac9ef3cc-5b69-11e7-aad9-9b03c205b85f", :freeswitch_hostname=>"wahoo-freeswitch", :freeswitch_switchname=>"wahoo-freeswitch", :freeswitch_ipv4=>"192.168.20.32", :freeswitch_ipv6=>"fe80::cc76:8ff:fee1:11e7", :event_date_local=>"2017-06-27 15:41:48", :event_date_gmt=>"Tue, 27 Jun 2017 20:41:48 GMT", :event_date_timestamp=>"1498596108425325", :event_calling_file=>"switch_scheduler.c", :event_calling_function=>"switch_scheduler_execute", :event_calling_line_number=>"71", :event_sequence=>"3258", :task_id=>"1", :task_desc=>"heartbeat", :task_group=>"core", :task_runtime=>"1498596128"}>

#<RubyFS::Event:0x00000002f7c270 @headers={:content_length=>"610", :content_type=>"text/event-json"}, @content={:event_name=>"RE_SCHEDULE", :core_uuid=>"ac9ef3cc-5b69-11e7-aad9-9b03c205b85f", :freeswitch_hostname=>"wahoo-freeswitch", :freeswitch_switchname=>"wahoo-freeswitch", :freeswitch_ipv4=>"192.168.20.32", :freeswitch_ipv6=>"fe80::cc76:8ff:fee1:11e7", :event_date_local=>"2017-06-27 15:41:48", :event_date_gmt=>"Tue, 27 Jun 2017 20:41:48 GMT", :event_date_timestamp=>"1498596108425325", :event_calling_file=>"switch_scheduler.c", :event_calling_function=>"switch_scheduler_execute", :event_calling_line_number=>"71", :event_sequence=>"3259", :task_id=>"2", :task_desc=>"check_ip", :task_group=>"core", :task_runtime=>"1498596168"}>

#<RubyFS::Event:0x00000002f34718 @headers={:content_length=>"1072", :content_type=>"text/event-json"}, @content={:event_subclass=>"sofia::register_attempt", :event_name=>"CUSTOM", :core_uuid=>"ac9ef3cc-5b69-11e7-aad9-9b03c205b85f", :freeswitch_hostname=>"wahoo-freeswitch", :freeswitch_switchname=>"wahoo-freeswitch", :freeswitch_ipv4=>"192.168.20.32", :freeswitch_ipv6=>"fe80::cc76:8ff:fee1:11e7", :event_date_local=>"2017-06-27 15:41:59", :event_date_gmt=>"Tue, 27 Jun 2017 20:41:59 GMT", :event_date_timestamp=>"1498596119385344", :event_calling_file=>"sofia_reg.c", :event_calling_function=>"sofia_reg_handle_register_token", :event_calling_line_number=>"1556", :event_sequence=>"3261", :profile_name=>"internal", :from_user=>"1011", :from_host=>"192.168.20.32", :contact=>"\"Kowalski\" <sip:10...@192.168.28.133:5060;transport=udp;fs_nat=yes;fs_path=sip%3A1011%40192.168.28.133%3A5060%3Btransport%3Dudp>", :call_id=>"095af75952d4546c", :rpid=>"unknown", :status=>"Registered(UDP-NAT)", :expires=>"30", :to_user=>"1011", :to_host=>"192.168.20.32", :network_ip=>"192.168.28.133", :network_port=>"5060", :username=>"1011", :realm=>"192.168.20.32", :user_agent=>"Aastra 6863i/3.3.1.7034", :auth_result=>"RENEWED"}>

. . . . JUST KEEPS GOING


Thanks,
John

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adhearsion+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

John Burke

unread,
Jun 29, 2017, 12:46:14 PM6/29/17
to Adhearsion
I'm still having some issues getting the code to work properly.  Here is the code snippet that I've got:

logger.info "log step . . . #0"
fs_stream_supervisor = RubyFS::Stream.supervise '192.168.20.32','8021','ClueCon',lambda{ |e| logger.info "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
logger.info e.inspect }
logger.info "log step . . . #1"
fs_stream = fs_stream_supervisor.actors.first
logger.info "log step . . . #2"
fs_stream.run
logger.info "log step . . . #3"
fs_stream.api 'api originate user/1000 XML john-test'


As soon as the program hits 'fs_stream.run' it enters a never ending loop where it receives events from freeswitch (shown in earlier posts).  For instance, it picks up DTMF events just fine, etc.  However, I can't execute anything because it seems to just be listening for events.  Any way to run the 'run' command concurrently or something?? 

I also stumbled upon another issue.  I commented out the loop { receive_data @socket.readpartial(4096) }  statement in the RubyFS::Stream class just to get the 'api originate user/1000 XML john-test' to execute and keep getting COMMAND NOT FOUND errors from freeswitch.  I was able to get the exact same command to originate a call in the fs_cli.  Any thoughts on this issue?

ngrep resutls
##
api originate user/1000 XML john-test


##
Content-Type: command/reply
Reply-Text: -ERR command not found


Thanks in advance for the help on the newbie questions!!!


Ben Langfeld

unread,
Jun 30, 2017, 4:47:53 AM6/30/17
to adhea...@googlegroups.com


Enviado do meu iPhone

Em 29 de jun de 2017, às 13:46, John Burke <jhnb...@gmail.com> escreveu:

I'm still having some issues getting the code to work properly.  Here is the code snippet that I've got:

logger.info "log step . . . #0"
fs_stream_supervisor = RubyFS::Stream.supervise '192.168.20.32','8021','ClueCon',lambda{ |e| logger.info "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
logger.info e.inspect }
logger.info "log step . . . #1"
fs_stream = fs_stream_supervisor.actors.first
logger.info "log step . . . #2"
fs_stream.run
logger.info "log step . . . #3"
fs_stream.api 'api originate user/1000 XML john-test'


As soon as the program hits 'fs_stream.run' it enters a never ending loop where it receives events from freeswitch (shown in earlier posts).  For instance, it picks up DTMF events just fine, etc.  However, I can't execute anything because it seems to just be listening for events.  Any way to run the 'run' command concurrently or something?? 

run! doesn't block. You can use that along with joining the actor (see Celluloid docs) to get your command in.

Alternatively you can execute commands only in response to events from FreeSWITCH. I'm sure there's some "connected" event you could use.

I also stumbled upon another issue.  I commented out the loop { receive_data @socket.readpartial(4096) }  statement in the RubyFS::Stream class just to get the 'api originate user/1000 XML john-test' to execute and keep getting COMMAND NOT FOUND errors from freeswitch.  I was able to get the exact same command to originate a call in the fs_cli.  Any thoughts on this issue?

ngrep resutls
##
api originate user/1000 XML john-test


##
Content-Type: command/reply
Reply-Text: -ERR command not found


Thanks in advance for the help on the newbie questions!!!


--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adhearsion+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages