Many thanks, I will hopefully be able to share what the problem was very soon. 
I am hoping after a good nights sleep, today I might be able to see the issue.

Lewis

From: Daniel-Constantin Mierla <[email protected]>
Sent: 27 January 2022 10:04
To: Kamailio (SER) - Users Mailing List <[email protected]>; Lewis 
Hutchinson <[email protected]>
Subject: Re: [SR-Users] 200 OK re transmission only on re-SUBSCRIBE


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 <[email protected]><mailto:[email protected]>
Sent: 26 January 2022 16:37
To: Kamailio (SER) - Users Mailing List 
<[email protected]><mailto:[email protected]>; Lewis 
Hutchinson 
<[email protected]><mailto:[email protected]>
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%7Cff717fb50bfc49d1b91e08d9e17c5dc4%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788747434568697%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=mUs5HI9I3DPonJHWvPv4Yl%2FEvzoQuD%2FSA1TJWawYJ0E%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

  * [email protected]<mailto:[email protected]>

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%7Cff717fb50bfc49d1b91e08d9e17c5dc4%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788747434568697%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=j3l%2BsE40v6yyKQw%2FSLvzMBjdN%2FP%2FaJlzmjAy9NuPcRM%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%7Cff717fb50bfc49d1b91e08d9e17c5dc4%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788747434568697%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=jp20nX4Y1Pk%2FqRddhdzjfnBuqUeMVZqlHxriFJdBMJU%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%7Cff717fb50bfc49d1b91e08d9e17c5dc4%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788747434568697%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=qVgJFf1eL%2FnEpYJH9EB6Pe60i3%2Bof4e%2Fb76JZ5MTrd4%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%7Cff717fb50bfc49d1b91e08d9e17c5dc4%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788747434568697%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=JtTJgQ9kKvmP5c4sCSx83nOa6dAzC10D0hEKKM3Q6b0%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%7Cff717fb50bfc49d1b91e08d9e17c5dc4%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788747434724907%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=aadNjjGug1W7KCvzOzMcIKeciLByeAK0ys7RAuK%2F6p0%3D&reserved=0>



__________________________________________________________

Kamailio - Users Mailing List - Non Commercial Discussions

  * [email protected]<mailto:[email protected]>

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%7Cff717fb50bfc49d1b91e08d9e17c5dc4%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788747434724907%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=rszwoOsHHcfSylU3mcB3fqRUlqCbjmXLC0tgrHDpjVE%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%7Cff717fb50bfc49d1b91e08d9e17c5dc4%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788747434724907%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=R0qcM%2Bd%2FSb%2BtqLv6jqhncTt7STIFhljiU27NG3gX3Aw%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%7Cff717fb50bfc49d1b91e08d9e17c5dc4%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788747434724907%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=QuWHJIivqvcfIT6fe8%2B8TB5PzZMdWcmioVTxOgHvj%2FM%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%7Cff717fb50bfc49d1b91e08d9e17c5dc4%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788747434724907%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=jsZ9vqERFDJUKuFHOcdyBRrQNZ7kcOEETUdd8ii%2Fy7s%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%7Cff717fb50bfc49d1b91e08d9e17c5dc4%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637788747434724907%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=aadNjjGug1W7KCvzOzMcIKeciLByeAK0ys7RAuK%2F6p0%3D&reserved=0>
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
  * [email protected]
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

Reply via email to