Daniel,

I am not sure if this enough but here are the changes that need to be done to have a basic test bed working:

kamailio.cfg:

loadmodule "app_python3.so"
modparam("app_python3", "load", "/etc/kamailio/kamailio.py")

route {
    if (is_method("INVITE")) {
        python_exec("display_headers")
    }
}

kamailio.py:

import KSR as KSR

def mod_init():
    KSR.xlog.xdbg("Python mod init.\n")
    return kamailio()

class kamailio:
    def __init__(self):
        KSR.xlog.xdbg("kamailio.__init__\n")

    def child_init(self, _):
        return 0

    def display_headers(self, _):
        KSR.xlog.xdbg("display_headers\n")

        header_name = "Geolocation"
        if KSR.hdr.is_present(header_name):
            i = 0
            header_value = KSR.hdr.get_idx(header_name, i)
            while header_value:
                KSR.xlog.xdbg("Found header value: {0} for header {1} \n".format(header_value, header_name))
                i += 1
                header_value = KSR.hdr.get_idx(header_name, i)

And your INVITE message then needs to have a Geolocation header. Something like: Geolocation: <cid:target123@atlanta.example.com>
Of course the header name shouldn't matter as long as it is in the INVITE.

Please let me know if this is enough or I should prepare something more.
I am currently also evaluating lua script for the same purpose to see if the same error is observed.

Pozdrawiam / Best regards,
Wojtek


On Mon, Apr 4, 2022 at 5:11 PM Daniel-Constantin Mierla <miconda@gmail.com> wrote:

I am not using Python module myself, although I helped adding Kemi support to it. It is not easy for me to create a testbed and try to reproduce. Maybe you can create a minimal config and a sipp scenario that can reproduce it. That could help the non-python developers to troubleshoot.

Cheers,
Daniel

On 01.04.22 15:40, Wojciech Kopciewicz wrote:
Any thoughts on this?

Pozdrawiam / Best regards,
Wojtek


On Fri, Feb 25, 2022 at 9:30 AM Wojciech Kopciewicz <wojciech.kopciewicz@motorolasolutions.com> wrote:
Hi Daniel,

This is still a development setup so the traffic is very small - a few calls a day.
It seems that the issue can be seen during first calls after some inactivity.

Pozdrawiam / Best regards,
Wojtek


On Wed, Feb 23, 2022 at 2:11 PM Daniel-Constantin Mierla <miconda@gmail.com> wrote:

Hello,

how often they show up and is there high volume of traffic at that moment?

Cheers,
Daniel

On 23.02.22 11:44, Wojciech Kopciewicz wrote:
Hi,

Yes, those values are hard-coded strings.

Pozdrawiam / Best regards,
Wojtek


On Wed, Feb 23, 2022 at 8:25 AM Daniel-Constantin Mierla <miconda@gmail.com> wrote:

Hello,

do you check that header_name parameter set for KSR.hdr.is_present() is a string value?

Cheers,
Daniel

On 22.02.22 15:36, Wojciech Kopciewicz wrote:

Hi,

Intermittently we are observing the following error when checking if given header is present in SIP INVITE:

SystemError: returned a result with an error set

The complete stack trace is (some names redacted):
11(28) ERROR: {1 195 INVITE nMHZDN.10nOIDt4ldOwz5cqz0XnMepA9} app_python3 [python_support.c:156]: python_handle_exception(): apy_exec: modify_headers((null)): Unhandled exception in the Python code:
TypeError: an integer is required (got type NoneType)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/etc/kamailio/kamailio.py", line 25, in modify_headers
self.modify_header("SomeHeader")
File "/etc/kamailio/kamailio.py", line 29, in modify_header
present = KSR.hdr.is_present(header_name)
SystemError: returned a result with an error set

Kamailio version (kamailio -v output):

version: kamailio 5.4.6 (x86_64/linux)

flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled with gcc 8.3.0

Operation system: Linux kamailio-5c7484c74d-vhhr8 5.4.0-1056-azure #58~18.04.1-Ubuntu SMP Wed Jul 28 23:14:18 UTC 2021 x86_64 GNU/Linux 

Are you able to help me find the root cause of this issue?

Pozdrawiam / Best regards,
Wojtek

For more information on how and why we collect your personal information, please visit our Privacy Policy.


__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
  * sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - Online
  Mar 28-31, 2022 (Europe Timezone)
  * https://www.asipto.com/sw/kamailio-advanced-training-online/

For more information on how and why we collect your personal information, please visit our Privacy Policy.

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - Online
  Mar 28-31, 2022 (Europe Timezone)
  * https://www.asipto.com/sw/kamailio-advanced-training-online/

For more information on how and why we collect your personal information, please visit our Privacy Policy.


__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
  * sr-users@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - Online
  March 28-31, 2022 (Europe Timezone)
  * https://www.asipto.com/sw/kamailio-advanced-training-online/

For more information on how and why we collect your personal information, please visit our Privacy Policy.