[SR-Users] app_ruby - KSR::PV.sets method not found

Andrew White andrew at uconnected.com.au
Sun Mar 31 08:44:47 CEST 2019


Hey Daniel,

Thanks for the patch!

It doesn’t appear to be throwing the error any longer. However as far as I can see, the value is not being set. Here’s the code, called from ksr_request_route()

def ksr_route_to_trunk()
  KSR.info("Route to trunk")
  if KSR::TM.t_is_set("failure_route") < 0 then
    KSR::TM.t_on_failure("ksr_failure_manage_trunk")
  end

  # Relay
  trunk = $redis_local.get("trunk") # Will probably eventually be a HSET
  uacs = get_all_uacs() 
  KSR.info("$fu is #{KSR::PV.gete("$fu")}")
  KSR.info("Updating to #{"sip:#{uacs[trunk]['r_username']}@#{uacs[trunk]['r_domain']}"}")
  KSR::PV.sets("$fu", "sip:#{uacs[trunk]['r_username']}@#{uacs[trunk]['r_domain']}”) 
  KSR.info("$fu rewritten to #{KSR::PV.gete("$fu")}”)
  replace_server_and_uac_header()
  KSR::TM.t_relay()
  exit
end

The output I get:

Mar 31 06:39:25 ip-10-0-0-2 /usr/local/sbin/kamailio[2361]: INFO: {1 102 INVITE 73bda23e5306c6fd4b31a0b615b47c0e} <core> [core/kemi.c:98]: sr_kemi_core_info(): Route to trunk
Mar 31 06:39:25 ip-10-0-0-2 /usr/local/sbin/kamailio[2361]: INFO: {1 102 INVITE 73bda23e5306c6fd4b31a0b615b47c0e} <core> [core/kemi.c:98]: sr_kemi_core_info(): $fu is sip:0390001234 at 127.0.0.1
Mar 31 06:39:25 ip-10-0-0-2 /usr/local/sbin/kamailio[2361]: INFO: {1 102 INVITE 73bda23e5306c6fd4b31a0b615b47c0e} <core> [core/kemi.c:98]: sr_kemi_core_info(): Updating to sip:123456 at sbc-syd-01.carrier.com
Mar 31 06:39:25 ip-10-0-0-2 /usr/local/sbin/kamailio[2361]: INFO: {1 102 INVITE 73bda23e5306c6fd4b31a0b615b47c0e} <core> [core/kemi.c:98]: sr_kemi_core_info(): $fu rewritten to sip: 0390001234 at 127.0.0.1

So it seems like KSR::PV.sets() is being called without issue, however when I KSR::PV.gete() for $fu it still holds the old value.

________________________________

Andrew White - Director
uConnected
Email: andrew at uconnected.com.au
Web: www.uConnected.com.au

> On 31 Mar 2019, at 12:25 am, Daniel-Constantin Mierla <miconda at gmail.com> wrote:
> 
> Hello,
> 
> can you try with master branch or with the patch from next commit?
> 
>   * https://github.com/kamailio/kamailio/commit/6d43eacd6d5b78fe857267e70b7fa85519a7d5b6 <https://github.com/kamailio/kamailio/commit/6d43eacd6d5b78fe857267e70b7fa85519a7d5b6>
> While looking at how is exported, I noticed that some param type checks were wrong. Let's see if that's fixing it or is something else.
> 
> Cheers,
> Daniel
> 
> On 30.03.19 05:45, Andrew White wrote:
>> Hi all,
>> 
>> I’m trying to set a pseudovariable via app_ruby. I’m able to retrieve pseudovariables using PV.gete as such:
>> 
>> 
>> However trying to set these using sets, I get “No method found”:
>> 
>> KSR::PV.sets("$fu", "sip:#{$uacs[trunk]['r_username']}@#{$uacs[trunk]['r_domain']}")
>> 
>> Mar 30 04:44:59 ip-10-0-0-2 /usr/local/sbin/kamailio[28421]: ERROR: {1 102 INVITE 0fae8097312bec2b5ec79ada30c227e7 at 127.0.0.1 <mailto:0fae8097312bec2b5ec79ada30c227e7 at 127.0.0.1>:5060} app_ruby [app_ruby_api.c:107]: app_ruby_print_last_exception(): exception: undefined method `[]' for nil:NilClass
>> 
>> PV.seti appears to work correctly. Am I calling the wrong method?
>> 
>> Thanks!
>> ________________________________
>> 
>> Andrew White - Director
>> uConnected
>> Email: andrew at uconnected.com.au <mailto:andrew at uconnected.com.au>
>> Web: www.uConnected.com.au <http://www.uconnected.com.au/>
>> 
>>  
>> 
>> 
>> 
>> _______________________________________________
>> Kamailio (SER) - Users Mailing List
>> sr-users at lists.kamailio.org <mailto:sr-users at lists.kamailio.org>
>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users <https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users>
> -- 
> Daniel-Constantin Mierla -- www.asipto.com <http://www.asipto.com/>
> www.twitter.com/miconda <http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda <http://www.linkedin.com/in/miconda>
> Kamailio World Conference - May 6-8, 2019 -- www.kamailioworld.com <http://www.kamailioworld.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20190331/8395d5c4/attachment.html>


More information about the sr-users mailing list