[SR-Users] Re: Kemi questions

2024-02-21 Thread Stefan-Cristian Mititelu via sr-users
Hi,

I have a follow-up question related to this.

I would like to use a python lib for mysql db connections and some simple 
queries(beside what other kama module queries). I tried to make a db connection 
per process in kemi "child_init()" function. All queries work ok for first and 
2'nd requests. However on 3'rd request received I get this error:


 kamailio[87876]: ERROR: db_mysql [km_dbase.c:122]: db_mysql_submit_query(): 
driver error on query: Lost connection to server during query (2013)
ERROR:  [db_query.c:141]: db_do_query_internal(): error while submitting 
query
ERROR: auth_db [authorize.c:178]: get_ha1(): failed to query database

The error goes away if I close the python db connection after each request. So 
it requires a new connect/disconnect for each request.

My questions are:

  1.  If I keep the python lib db connection per process, it should be 
available among new requests, right?
  2.  Is the above a bug when I do KSR.auth_db.auth_check(str,str,int)?

Thank you,
Stefan

From: Stefan-Cristian Mititelu via sr-users 
Sent: Tuesday, December 5, 2023 4:15:47 PM
To: Kamailio (SER) - Users Mailing List
Cc: Stefan-Cristian Mititelu
Subject: [SR-Users] Re: Kemi questions


Thank you,
Stefan


From: Daniel-Constantin Mierla 
Sent: Tuesday, December 5, 2023 4:06:08 PM
To: Kamailio (SER) - Users Mailing List
Cc: Stefan-Cristian Mititelu
Subject: Re: [SR-Users] Kemi questions

Hello,

On 05.12.23 14:50, Stefan-Cristian Mititelu via sr-users wrote:

Hello,

When writing kemi cfg (python in my case), is there any way to get rid of 
standard cfg shared variables and use kemi cfg variables instead?


E.g. Instead of $shv(blabla) (in standard config) can I use some global python 
var called 'blabla'? Is it seen and shared by all kamailio processes? Or I 
still need to use KSR.pv.get/set("$shv(blabla)") ?

the global python native variables are per process, so you can't replace 
$shv(...) with them. The python ones are more like $var(...) from kamailio.


However, instead of the generic KSR.pv.get/set(), you can use the alternative 
KEMI functions -- see them starting at:


  - 
https://www.kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/modules/#ksrpvxshv_get


Cheers,
Daniel


--
Daniel-Constantin Mierla (@ asipto.com)
twitter.com/miconda -- linkedin.com/in/miconda
Kamailio Consultancy and Development Services
Kamailio Advanced Training -- asipto.com
__
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:


[SR-Users] Re: Kemi questions

2023-12-05 Thread Stefan-Cristian Mititelu via sr-users
Thank you,
Stefan


From: Daniel-Constantin Mierla 
Sent: Tuesday, December 5, 2023 4:06:08 PM
To: Kamailio (SER) - Users Mailing List
Cc: Stefan-Cristian Mititelu
Subject: Re: [SR-Users] Kemi questions

Hello,

On 05.12.23 14:50, Stefan-Cristian Mititelu via sr-users wrote:

Hello,

When writing kemi cfg (python in my case), is there any way to get rid of 
standard cfg shared variables and use kemi cfg variables instead?


E.g. Instead of $shv(blabla) (in standard config) can I use some global python 
var called 'blabla'? Is it seen and shared by all kamailio processes? Or I 
still need to use KSR.pv.get/set("$shv(blabla)") ?

the global python native variables are per process, so you can't replace 
$shv(...) with them. The python ones are more like $var(...) from kamailio.


However, instead of the generic KSR.pv.get/set(), you can use the alternative 
KEMI functions -- see them starting at:


  - 
https://www.kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/modules/#ksrpvxshv_get


Cheers,
Daniel


--
Daniel-Constantin Mierla (@ asipto.com)
twitter.com/miconda -- linkedin.com/in/miconda
Kamailio Consultancy and Development Services
Kamailio Advanced Training -- asipto.com
__
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:


[SR-Users] Re: Kemi questions

2023-12-05 Thread Daniel-Constantin Mierla via sr-users
Hello,

On 05.12.23 14:50, Stefan-Cristian Mititelu via sr-users wrote:
>
> Hello,
>
> When writing kemi cfg (python in my case), is there any way to get rid
> of standard cfg shared variables and use kemi cfg variables instead?
>
>
> E.g. Instead of $shv(blabla) (in standard config) can I use some
> global python var called 'blabla'? Is it seen and shared by all
> kamailio processes? Or I still need to use
> KSR.pv.get/set("$shv(blabla)") ?
>
the global python native variables are per process, so you can't replace
$shv(...) with them. The python ones are more like $var(...) from kamailio.


However, instead of the generic KSR.pv.get/set(), you can use the
alternative KEMI functions -- see them starting at:


  -
https://www.kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/modules/#ksrpvxshv_get


Cheers,
Daniel


-- 
Daniel-Constantin Mierla (@ asipto.com)
twitter.com/miconda -- linkedin.com/in/miconda
Kamailio Consultancy and Development Services
Kamailio Advanced Training -- asipto.com
__
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe: