Hi,
I was wondering if it is possible of keeping the request_route as native configuration, while replacing certain route blocks such as AUTH/REGISTRAR with python KEMI instead?
The idea is to implement RFC8898, which basically requires me to challenge for bearer token and validate it afterwards if returned by the client. For my convencience, I had defined the AUTH and REGISTRAR block in python KEMI, and was calling them as such:
request_route { ...
$var(auth_route_ret) = python_exec("ksr_route_auth", "test\n"); xlog("$var(debug_level)", "[KSR_AUTH] Return code Kamailio is $var(auth_route_ret)"); if ($var(auth_route_ret) == -255) { exit; }
... $var(registrar_route_ret) = python_exec("ksr_route_registrar", "test\n"); xlog("$var(debug_level)", "[KSR_REGISTRAR] REGISTRAR return code Kamailio is $var(registrar_route_ret)"); if ($var(registrar_route_ret) == -255) { exit; } ...
}
While the register itself seems to work, it seems that other blocks seem to fail as they would likely expect KSR?
ERROR: {1 112367482 INVITE f0af27cd-9d75-123f-79a9-b4e9b8034b4e} <core> [core/kemi.c:3772]: sr_kemi_cbname_lookup_idx(): index 1 is out of range
Any idea if this would be possible, or should I determine wether to go native cfg or KEMI?
Best regards, Dries
Hi,
IMHO, you would be better off doing this as classic inline Python (e.g. via app_python3), rather than via KEMI.
Cheers,
-- Alex
On Mar 18, 2026, at 10:20 AM, Dries De Gendt via sr-users sr-users@lists.kamailio.org wrote:
Hi,
I was wondering if it is possible of keeping the request_route as native configuration, while replacing certain route blocks such as AUTH/REGISTRAR with python KEMI instead?
The idea is to implement RFC8898, which basically requires me to challenge for bearer token and validate it afterwards if returned by the client. For my convencience, I had defined the AUTH and REGISTRAR block in python KEMI, and was calling them as such:
request_route { ...
$var(auth_route_ret) = python_exec("ksr_route_auth", "test\n"); xlog("$var(debug_level)", "[KSR_AUTH] Return code Kamailio is $var(auth_route_ret)"); if ($var(auth_route_ret) == -255) { exit; }
... $var(registrar_route_ret) = python_exec("ksr_route_registrar", "test\n"); xlog("$var(debug_level)", "[KSR_REGISTRAR] REGISTRAR return code Kamailio is $var(registrar_route_ret)"); if ($var(registrar_route_ret) == -255) { exit; } ...
}
While the register itself seems to work, it seems that other blocks seem to fail as they would likely expect KSR?
ERROR: {1 112367482 INVITE f0af27cd-9d75-123f-79a9-b4e9b8034b4e} <core> [core/kemi.c:3772]: sr_kemi_cbname_lookup_idx(): index 1 is out of range
Any idea if this would be possible, or should I determine wether to go native cfg or KEMI?
Best regards, Dries __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org 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!
-- Alex Balashov Principal Consultant Evariste Systems LLC Web: https://evaristesys.com, https://www.csrpswitch.com Tel: +1-706-510-6800
Hello,
this approach should work, maybe there are some errors in your python scripts, try to run with debug=3 in kamailio config and see if you get more debug messages around the error that could give some hints about what happens there.
Cheers, Daniel
On 18.03.26 15:20, Dries De Gendt via sr-users wrote:
Hi,
I was wondering if it is possible of keeping the request_route as native configuration, while replacing certain route blocks such as AUTH/REGISTRAR with python KEMI instead?
The idea is to implement RFC8898, which basically requires me to challenge for bearer token and validate it afterwards if returned by the client. For my convencience, I had defined the AUTH and REGISTRAR block in python KEMI, and was calling them as such:
request_route { ...
$var(auth_route_ret) = python_exec("ksr_route_auth", "test\n"); xlog("$var(debug_level)", "[KSR_AUTH] Return code Kamailio is $var(auth_route_ret)"); if ($var(auth_route_ret) == -255) { exit; }
... $var(registrar_route_ret) = python_exec("ksr_route_registrar", "test\n"); xlog("$var(debug_level)", "[KSR_REGISTRAR] REGISTRAR return code Kamailio is $var(registrar_route_ret)"); if ($var(registrar_route_ret) == -255) { exit; } ...
}
While the register itself seems to work, it seems that other blocks seem to fail as they would likely expect KSR?
ERROR: {1 112367482 INVITE f0af27cd-9d75-123f-79a9-b4e9b8034b4e} <core> [core/kemi.c:3772]: sr_kemi_cbname_lookup_idx(): index 1 is out of range
Any idea if this would be possible, or should I determine wether to go native cfg or KEMI?
Best regards, Dries __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org 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!
Hi Daniel,
Thanks for confirming. After removing 'cfgengine "python"' from the configuration, it appears to work correctly.
Best regards, Dries