Experimenting with KEMI for the first time, I ran into a few issues and hoping someone has feedback.
kamailio 5.8.3
In the following python example, 'if ksr.is_method("ACK"):' should never be reached. Below is debug.
if not ksr.siputils.has_totag(): ksr.info("has to tag") sys.exit()
if ksr.is_method("ACK"): if ksr.tm.t_check_trans(): ksr.relay() sys.exit) else: sys.exit() ksr.sl.send_reply(404, "Not here") sys,exit()
..... DEBUG: app_python3s [apy3s_kemi.c:365]: sr_apy_kemi_exec_func_ex(): execution of method: siputils.has_totag DEBUG: siputils [checks.c:122]: has_totag(): no totag DEBUG: app_python3s [apy3s_kemi.c:368]: sr_apy_kemi_exec_func_ex(): execution of method: is_method DEBUG: app_python3s [apy3s_kemi.c:389]: sr_apy_kemi_exec_func_ex(): number of arguments: 1 DEBUG: app_python3s [apy3s_kemi.c:365]: sr_apy_kemi_exec_func_ex(): execution of method: sl.send_reply DEBUG: app_python3s [apy3s_kemi.c:389]: sr_apy_kemi_exec_func_ex(): number of arguments: 2 DEBUG: sl [sl.c:306]: send_reply(): reply in stateless mode (sl) .....
Second, here are a couple errors I have seen a few times but havent been able to identify the underlying issue, mainly hoping for more context on the meaning of 'execution of route type 1 with no name returned -1'.
ERROR: app_python3s [apy3s_kemi.c:146]: apy3s_exec_func(): error exception occurred
DEBUG: app_python3s [apy3s_kemi.c:230]: sr_kemi_config_engine_python(): execution of route type 1 with no name returned -1
Any input is appreciated.
* dan
Daniel, first check and fix sys.exit) -> sys.exit() and sys,exit() -> sys.exit()
Replace sys.exit() with `return` to avoid abruptly stopping the Kamailio process.
try it:
if not ksr.siputils.has_totag(): ksr.info("has to tag") return
if ksr.is_method("ACK"): if ksr.tm.t_check_trans(): ksr.relay() return else: return ksr.sl.send_reply(404, "Not here") return
regards!
Return yields the same results. I previously used return but changed to sys.exit() based on KEMI documentation page, I may have mis-interpreted the direction there. The comma was a typo in the email.
Thanks for the pointers. -dan ________________________________ From: Ricardo Castillo via sr-users sr-users@lists.kamailio.org Sent: Tuesday, November 12, 2024 18:00 To: sr-users@lists.kamailio.org sr-users@lists.kamailio.org Cc: Ricardo Castillo pkecastillo@gmail.com Subject: [SR-Users] Re: KEMI / Python Issues
Caution: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe
Daniel, first check and fix sys.exit) -> sys.exit() and sys,exit() -> sys.exit()
Replace sys.exit() with `return` to avoid abruptly stopping the Kamailio process.
try it:
if not ksr.siputils.has_totag(): ksr.info("has to tag") return
if ksr.is_method("ACK"): if ksr.tm.t_check_trans(): ksr.relay() return else: return ksr.sl.send_reply(404, "Not here") return
regards! __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
I took a look at source for siputils module. This function returns -1 so the python syntax I'm using won't work here.
'if not' expects 0/false as return value. -dan
________________________________ From: Daniel W. Graham via sr-users sr-users@lists.kamailio.org Sent: Tuesday, November 12, 2024 19:13 To: sr-users@lists.kamailio.org sr-users@lists.kamailio.org Cc: Daniel W. Graham dan@cmsinter.net Subject: [SR-Users] Re: KEMI / Python Issues
Caution: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe
Return yields the same results. I previously used return but changed to sys.exit() based on KEMI documentation page, I may have mis-interpreted the direction there. The comma was a typo in the email.
Thanks for the pointers. -dan ________________________________ From: Ricardo Castillo via sr-users sr-users@lists.kamailio.org Sent: Tuesday, November 12, 2024 18:00 To: sr-users@lists.kamailio.org sr-users@lists.kamailio.org Cc: Ricardo Castillo pkecastillo@gmail.com Subject: [SR-Users] Re: KEMI / Python Issues
Caution: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe
Daniel, first check and fix sys.exit) -> sys.exit() and sys,exit() -> sys.exit()
Replace sys.exit() with `return` to avoid abruptly stopping the Kamailio process.
try it:
if not ksr.siputils.has_totag(): ksr.info("has to tag") return
if ksr.is_method("ACK"): if ksr.tm.t_check_trans(): ksr.relay() return else: return ksr.sl.send_reply(404, "Not here") return
regards! __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
It might be necessary to return 1
using the same example:
if not ksr.siputils.has_totag(): ksr.info("has to tag") return
if ksr.is_method("ACK"): if ksr.tm.t_check_trans(): ksr.relay() return else: return ksr.sl.send_reply(404, "Not here") return 1
I was able to resolve the remaining errors by removing sys.exit() and replacing with return / return 1.
Any thoughts on what these debug lines are referring to? (what is route type and should name have a value?)
DEBUG: app_python3s [apy3s_kemi.c:227]: sr_kemi_config_engine_python(): execution of route type 513 with name [] returned -1 DEBUG: app_python3s [apy3s_kemi.c:230]: sr_kemi_config_engine_python(): execution of route type 1 with no name returned 1 - dan ________________________________ From: Ricardo Castillo via sr-users sr-users@lists.kamailio.org Sent: Wednesday, November 13, 2024 07:16 To: sr-users@lists.kamailio.org sr-users@lists.kamailio.org Cc: Ricardo Castillo pkecastillo@gmail.com Subject: [SR-Users] Re: KEMI / Python Issues
Caution: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe
It might be necessary to return 1
using the same example:
if not ksr.siputils.has_totag(): ksr.info("has to tag") return
if ksr.is_method("ACK"): if ksr.tm.t_check_trans(): ksr.relay() return else: return ksr.sl.send_reply(404, "Not here") return 1 __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
Daniel try using (try / except) for more debug or apply more verbose.
For it msg "execution of route type 1 with no name returned 1" use return -1 an try again.
try: # your code here except Exception as e: ksr.err(f"Exception occurred: {str(e)}") return
regards Richard
There are no exceptions raised, that output is only in kamailio debug. Was just curious what its meaning was.
-dan ________________________________ From: Ricardo Castillo via sr-users sr-users@lists.kamailio.org Sent: Thursday, November 14, 2024 03:53 To: sr-users@lists.kamailio.org sr-users@lists.kamailio.org Cc: Ricardo Castillo pkecastillo@gmail.com Subject: [SR-Users] Re: KEMI / Python Issues
Caution: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe
Daniel try using (try / except) for more debug or apply more verbose.
For it msg "execution of route type 1 with no name returned 1" use return -1 an try again.
try: # your code here except Exception as e: ksr.err(f"Exception occurred: {str(e)}") return
regards Richard __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: