[SR-Users] 200 OK re transmission only on re-SUBSCRIBE

Daniel-Constantin Mierla miconda at gmail.com
Thu Jan 27 11:03:58 CET 2022


Hello,

you have to look at your routing script and see if it is missing some
return or exit to stop processing when the reply is sent out.

Cheers,
Daniel

On 26.01.22 18:22, Lewis Hutchinson wrote:
>
> Hi Daniel
>
>  
>
> Many thanks, this is in the early stages and to undergo extensive
> testing which I suspect will see a lot efforts to improve and refine.
> This was previously written in native kamailio but for other reasons
> moved to python. Any feedback always welcome
>
> “looks like after sending the response execution continues somewhere
> else hitting t_check_trans() which detect the transaction exists and
> re-sends the last last reply (as it is supposed to behave).” can you
> think why this only occur on a re SUBSCRIBE
>
> There is no intelligence in the reply needed just an accurate response
> from the API transformed into a reply 200, 500 etc etc
>
>
>
> *Lewis *
>
>  
>
> *From:*Daniel-Constantin Mierla <miconda at gmail.com>
> *Sent:* 26 January 2022 16:37
> *To:* Kamailio (SER) - Users Mailing List
> <sr-users at lists.kamailio.org>; Lewis Hutchinson
> <lewis.hutchinson at missionlabs.co.uk>
> *Subject:* Re: [SR-Users] 200 OK re transmission only on re-SUBSCRIBE
>
>  
>
> Hello,
>
> looks like after sending the response execution continues somewhere
> else hitting t_check_trans() which detect the transaction exists and
> re-sends the last last reply (as it is supposed to behave).
>
> Be also careful with async processing in python, I am not familiar
> with it at all, just be aware that kamailio has a multi-process design
> and uses per-process global variables. if you do multi-threading async
> processing in python, be sure you ensure consistency of globals and
> avoid races to read+change them.
>
> Cheers,
> Daniel
>
> On 26.01.22 16:53, Lewis Hutchinson wrote:
>
>     First of all I should start by saying this is my first post so go
>     easy on me!! : ) and thank for everyone’s efforts to share
>     knowledge it has been invaluable for my kamailio learning.
>
>     _Build Details_
>
>     Version: kamailio 5.5.3 (x86_64/linux)
>     Kamailio kemi python
>
>     _Scenario_
>
>     Relevant config
>
>     def ksr_route_api_query(self, msg):
>
>             KSR.log("info", "SUBSCRIBE API Query Starts")
>
>      
>
>             # Create new Transaction
>
>             KSR.tm.t_newtran()
>
>      
>
>             async def main():
>
>                 url = 'https://api.hidingtheurl.com/subscribe
>     <https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapi.hidingtheurl.com%2Fsubscribe&data=04%7C01%7Clewis.hutchinson%40missionlabs.co.uk%7Cdd21c3bd426b483f046908d9e0ea0e56%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788119843865974%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=RUXou2G%2F5kC2rT2VKu%2BJ3YQKvimpUxe4HsyMjfqXAUk%3D&reserved=0>'
>
>                 payload = {
>
>                     "ruri": KSR.pv.get("$ru"),
>
>                     "from": KSR.pv.get("$fu"),
>
>                     "from_tag": KSR.pv.gete("$ft"),
>
>                     "to": KSR.pv.get("$tu"),
>
>                     "callid": KSR.pv.get("$ci"),
>
>                     "cseq": KSR.pv.get("$cs"),
>
>                     "contact": KSR.pv.gete("$ct"),
>
>                     "supported": KSR.pv.get("$hdr(Supported)"),
>
>                     "event": KSR.pv.get("$hdr(Event)"),
>
>                     "expires": KSR.pv.get("$hdr(Expires)"),
>
>                     "diversion": KSR.pv.get("$di"),
>
>                     "body": KSR.pv.get("$rb")
>
>                     }
>
>                 async with aiohttp.ClientSession() as session:
>
>                     async with session.post(url, json=payload) as
>     response:
>
>                         if response.status == 0:
>
>                             KSR.xlog.xinfo(f"SUB Manager Timeout:
>     {response.status}")
>
>                             KSR.tm.t_reply(408, "SUB Manager Timeout")
>
>                         elif response.status >= 500:
>
>                             KSR.xlog.xinfo(f"SUB Manager Down:
>     {response.status}")
>
>                             KSR.tm.t_reply(500, "SUB Manager Down")
>
>                         elif response.status >= 400:
>
>                             KSR.xlog.xinfo(f"SUB Manager Error:
>     {response.status}")
>
>                             KSR.tm.t_reply(400, "SUB Manager Error")
>
>                         else:
>
>                             if response.status == 200:
>
>                                 KSR.xlog.xinfo(f"SUB Manager Success:
>     {response.status}")
>
>                                 KSR.tm.t_reply(200, "OK")
>
>      
>
>             KSR.log("info", "SUBSCRIBE API Query Ends")
>
>             asyncio.run(main())
>
>             # API Query Ends
>
>     _Scenario_
>
>
>     Initial SUBSCRIBE >>> hits Kamailio >>> send payload in JSON to
>     API get receive 200OK response from API and send a 200OK on to Device
>
>      
>
>     SUBSCRIBE -------->
>
>     <------------ 200 OK
>
>      
>
>     After Subscription Expiry
>
>      
>
>     re-SUBSCRIBE >>> hits Kamailio >>> send payload in JSON to API get
>     200OK response from API and send a 200OK on to Device but also
>     another 200OK a fraction of a second later...
>
>      
>
>     SUBSCRIBE -------->
>
>     <------------ 200 OK
>
>     <<<--------- 200 OK
>
>      
>
>
>     This happens for all following re-SUBSCRIBE's
>
>      
>
>     The 200 OK are identical, and it is a re transmission, but I can’t
>     work out why..
>
>     Relevant DEBUG is below
>
>     Jan 26 12:31:17 ip-172-20-46-39 kamailio[11234]: INFO: <script>:
>     SUB Manager Success: 200
>
>     Jan 26 12:31:17 ip-172-20-46-39 kamailio[11234]: DEBUG:
>     app_python3 [apy_kemi.c:232]: sr_apy_kemi_exec_func_ex():
>     execution of method: t_reply
>
>     Jan 26 12:31:17 ip-172-20-46-39 kamailio[11234]: DEBUG:
>     app_python3 [apy_kemi.c:287]: sr_apy_kemi_exec_func_ex():
>     params[2] for: t_reply are int-str: [200] [OK]
>
>     Jan 26 12:31:17 ip-172-20-46-39 kamailio[11234]: DEBUG: tm
>     [t_lookup.c:1034]: t_check_msg(): msg (0x7eff0cd4e828) id=2/11234
>     global id=2/11234 T start=0x7eff0918d7d8
>
>     Jan 26 12:31:17 ip-172-20-46-39 kamailio[11234]: DEBUG: tm
>     [t_lookup.c:1108]: t_check_msg(): T (0x7eff0918d7d8) already found
>     for msg (0x7eff0cd4e828)!
>
>     Jan 26 12:31:17 ip-172-20-46-39 kamailio[11234]: DEBUG: <core>
>     [core/msg_translator.c:162]: check_via_address(): (80.111.111.111,
>     80.111.111.111, 0)
>
>     Jan 26 12:31:17 ip-172-20-46-39 kamailio[11234]: DEBUG: tm
>     [t_reply.c:1763]: cleanup_uac_timers(): RETR/FR timers reset
>
>     Jan 26 12:31:17 ip-172-20-46-39 kamailio[11234]: DEBUG: tm
>     [t_reply.c:637]: _reply_light(): reply sent out -
>     buf=0x7eff0cd50938: SIP/2.0 200 OK#015#012Via:...
>     shmem=0x7eff09190ca8: SIP/2.0 200 OK#015#012Via:
>
>     Jan 26 12:31:17 ip-172-20-46-39 kamailio[11234]: DEBUG: tm
>     [t_reply.c:648]: _reply_light(): finished
>
>      
>
>     Jan 26 12:31:17 ip-172-20-46-39 kamailio[11234]: DEBUG:
>     app_python3 [apy_kemi.c:232]: sr_apy_kemi_exec_func_ex():
>     execution of method: t_precheck_trans
>
>     Jan 26 12:31:17 ip-172-20-46-39 kamailio[11234]: DEBUG:
>     app_python3 [apy_kemi.c:232]: sr_apy_kemi_exec_func_ex():
>     execution of method: t_check_trans
>
>     Jan 26 12:31:17 ip-172-20-46-39 kamailio[11234]: DEBUG: tm
>     [t_lookup.c:1034]: t_check_msg(): msg (0x7eff0cd4e828) id=2/11234
>     global id=2/11234 T start=0x7eff0918d7d8
>
>     Jan 26 12:31:17 ip-172-20-46-39 kamailio[11234]: DEBUG: tm
>     [t_lookup.c:1108]: t_check_msg(): T (0x7eff0918d7d8) already found
>     for msg (0x7eff0cd4e828)!
>
>     Jan 26 12:31:17 ip-172-20-46-39 kamailio[11234]: DEBUG: tm
>     [t_reply.c:1703]: t_retransmit_reply(): reply retransmitted.
>     buf=0x7eff0cb18220: SIP/2.0 2..., shmem=0x7eff09190ca8: SIP/2.0 2
>
>     Jan 26 12:31:17 ip-172-20-46-39 kamailio[11234]: DEBUG:
>     app_python3 [apy_kemi.c:112]: sr_kemi_config_engine_python():
>     execution of route type 1 with no name returned 1
>
>     Jan 26 12:31:17 ip-172-20-46-39 kamailio[11234]: DEBUG: <core>
>     [core/receive.c:514]: receive_msg(): request-route executed in:
>     38258 usec
>
>
>     Everything works well as is but I want to clean up this issue or
>     at least understand what is causing it.
>
>
>
>      
>
>     *Lewis*
>
>
>
>     __________________________________________________________
>
>     Kamailio - Users Mailing List - Non Commercial Discussions
>
>       * sr-users at 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 <https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.kamailio.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fsr-users&data=04%7C01%7Clewis.hutchinson%40missionlabs.co.uk%7Cdd21c3bd426b483f046908d9e0ea0e56%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788119843875940%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=ktFWCyiPBcm1lBD%2FufKC29cRDas8w40bz%2B%2FeqlKU4ME%3D&reserved=0>
>
> -- 
> Daniel-Constantin Mierla -- www.asipto.com <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.asipto.com%2F&data=04%7C01%7Clewis.hutchinson%40missionlabs.co.uk%7Cdd21c3bd426b483f046908d9e0ea0e56%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788119843885892%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=sWTHp6KL5rN4GUE0AE8bjcPZ%2FY15ogA3kXohl8pFPlU%3D&reserved=0>
> www.twitter.com/miconda <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.twitter.com%2Fmiconda&data=04%7C01%7Clewis.hutchinson%40missionlabs.co.uk%7Cdd21c3bd426b483f046908d9e0ea0e56%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788119843885892%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=9aZF1fGLjKeQHQjJh6EtQoM%2FguP78pdwEmec7wRl%2FeY%3D&reserved=0> -- www.linkedin.com/in/miconda <https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.linkedin.com%2Fin%2Fmiconda&data=04%7C01%7Clewis.hutchinson%40missionlabs.co.uk%7Cdd21c3bd426b483f046908d9e0ea0e56%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788119843895840%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=M6Eisb%2FqYQ%2FnBEK8zF2vbhCycOPtGT%2B6rV3coVO6Ebo%3D&reserved=0>
> Kamailio Advanced Training - Online
>   Feb 21-24, 2022 (America Timezone)
>   * https://www.asipto.com/sw/kamailio-advanced-training-online/ <https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.asipto.com%2Fsw%2Fkamailio-advanced-training-online%2F&data=04%7C01%7Clewis.hutchinson%40missionlabs.co.uk%7Cdd21c3bd426b483f046908d9e0ea0e56%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788119843905804%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=O2YyPhALtsIevNfiWMTXdK2GMaeZ91GU%2B1ebo%2BC%2Fx9E%3D&reserved=0>
>
> __________________________________________________________
> Kamailio - Users Mailing List - Non Commercial Discussions
>   * sr-users at 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
  Feb 21-24, 2022 (America Timezone)
  * https://www.asipto.com/sw/kamailio-advanced-training-online/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20220127/13222d21/attachment.htm>


More information about the sr-users mailing list