<p></p>

<h3 dir="auto">Description</h3>
<p dir="auto">using KEMI API in Python v2.7.18 for Kamailio v5.6.2, I encounter error in <code class="notranslate">ksr_onsend_route</code>, it always gives following error,</p>
<pre class="notranslate"><code class="notranslate">ERROR: app_python [python_support.c:154]: python_handle_exception(): apy_exec: ksr_onsend_route((null)): Unhandled exception in the Python code: 
TypeError: an integer is required
</code></pre>

<h3 dir="auto">Troubleshooting</h3>
<p dir="auto">Above error happens even if there is no code in this function and it returns success, e.g.</p>
<div class="highlight highlight-source-python" dir="auto"><pre>...
    <span class="pl-k">def</span> <span class="pl-en">ksr_onsend_route</span>(<span class="pl-s1">self</span>, <span class="pl-s1">msg</span>):
        <span class="pl-k">return</span> <span class="pl-c1">1</span>

...</pre></div>
<h4 dir="auto">Reproduction</h4>
<p dir="auto">It happens always whenever <code class="notranslate">ksr_onsend_route</code> function exists in <code class="notranslate">kamailio</code> class in KEMI python configuration for kamailio.</p>

<h4 dir="auto">Debugging Data</h4>
<p dir="auto">Nothing relevant in debug even with <code class="notranslate">debug=9</code> set.</p>

<h4 dir="auto">Log Messages</h4>

<pre class="notranslate"><code class="notranslate">ERROR: app_python [python_support.c:154]: python_handle_exception(): apy_exec: ksr_onsend_route((null)): Unhandled exception in the Python code: 
TypeError: an integer is required
</code></pre>
<h4 dir="auto">SIP Traffic</h4>

<pre class="notranslate"><code class="notranslate">REGISTER sip:voip-test.sip-domain.de:5060 SIP/2.0.
Via: SIP/2.0/UDP x.x.x.x:5060;branch=z9hG4bK-1523596-64-0.
From: <sip:490000063@voip-test.sip-domain.de:5060>;tag=64.
To: <sip:490000063@voip-test.sip-domain.de:5060>.
Call-ID: call_id_64.
CSeq: 1 REGISTER.
Contact: sip:490000063@x.x.x.x:5060.
Max-Forwards: 70.
Content-Length: 0.
..

</code></pre>
<h3 dir="auto">Possible Solutions</h3>
<p dir="auto">I suspect the problem is at low level (native code) of app_python module.</p>

<h3 dir="auto">Additional Information</h3>
<ul dir="auto">
<li><strong>Kamailio Version</strong> - output of <code class="notranslate">kamailio -v</code></li>
</ul>
<pre class="notranslate"><code class="notranslate">version: kamailio 5.6.2 (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_BLOCKLIST, 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:  
compiled with gcc 10.2.1
</code></pre>
<pre class="notranslate"><code class="notranslate">Python 2.7.18
</code></pre>
<ul dir="auto">
<li><strong>Operating System</strong>:</li>
</ul>

<pre class="notranslate"><code class="notranslate">Linux test-sip-server 5.10.0-17-amd64 #1 SMP Debian 5.10.136-1 (2022-08-13) x86_64 GNU/Linux
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/3274">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZL6SJCEC6P74KSNTD3WGJCSPANCNFSM6AAAAAARU6NH6Y">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/ABO7UZO3YNSXILTFNP725T3WGJCSPA5CNFSM6AAAAAARU6NH62WGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHFK2HXZA.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><kamailio/kamailio/issues/3274</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/3274",
"url": "https://github.com/kamailio/kamailio/issues/3274",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>