[sr-dev] [kamailio/kamailio] Kamailio 5.3 app_ruby crashed with example config (#2180)

Odorik.cz notifications at github.com
Wed Jan 8 11:42:51 CET 2020


**Ruby script: /var/kamailio/ruby/test.rb**

```
def pv_get(pvn)
  KSR::PV.get(pvn)
end

def log(mess)
  KSR.info(mess.to_s)
end

def pv_set(pvn, val, type)
  case type
  when :i
    KSR::PV.seti(pvn, val)
  when :s
    KSR::PV.sets(pvn, val)
  end
end

def sl_reply(code, mess)
  KSR::SL.sl_send_reply(code, mess)
end

def start
  income = {}
 
  ['$rm', '$ci', '$si', '$rU', '$rd', '$ft'].each do |pv|
    income[pv[1..-1].to_sym] = pv_get(pv)
  end

  log("RUBY - #{KSR.is_INVITE} - #{pv_get('$si')}")
  log(income.to_s)
  pv_set('$var(tmp)', 12345, :i)

  sl_reply(200, 'OK-Ruby')
end
```


**kamailio.cfg is default except:**

```
loadmodule "app_ruby.so"
.....
modparam("app_ruby", "load", "/var/kamailio/ruby/test.rb")
....
  # handle requests within SIP dialogs
  route(WITHINDLG);
  
  ### only initial requests (no To tag)
  
  # authentication
  route(AUTH);
    
  # record routing for dialog forming requests (in case they are routed)
  # - remove preloaded route headers
  remove_hf("Route");
  if (is_method("INVITE|SUBSCRIBE")) {
    record_route();
    if(!ruby_run("start")) {
      xlogl("L_INFO","SCRIPT: failed to execute ruby function! start");
    }
    xlog("L_INFO","RUBY -- $var(tmp)");
  } 
```


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2180#issuecomment-571992731
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20200108/f495fdbd/attachment.html>


More information about the sr-dev mailing list