[kamailio/kamailio] Dialog: Timeout/dlg_bye randomly doesn't send BYE message (Issue #4169)
Mercury109 created an issue (kamailio/kamailio#4169) ### Description I loop through the active dialogs in a timer functions and based on some conditions, a dialog may be ended by setting a short timeout or using the dlg_bye function. **Sometimes** when a dialog times out or the dlg_bye("all") function is used, the BYE is not being sent in both directions, only towards the caller. There's a warning: send_bye(): dlg [25641:71143] with callid XXXXXXXXX already in deleted state, BYE not sent. I noticed this check was added in the commit below: https://github.com/kamailio/kamailio/commit/d411c6ea4358e6d9dd367349e877ed5f... Is there a race condition between marking the dialog as terminated and sending the BYE? Not sending a BYE towards the callee when it should is much worse than sending an unnecessary BYE as it causes billing issues. If this can't be resolved to be 100% reliable, it's safer to remove this check all together. ### Additional Information * **Kamailio Version** - output of `kamailio -v` ``` version: kamailio 5.7.6 (x86_64/linux)) ``` * **Operating System**: Debian GNU/Linux 12 (bookworm) -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/4169 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/issues/4169@github.com>
henningw left a comment (kamailio/kamailio#4169) Thanks for the report. From the linked commit it looks that the dialog is already deleted for some reasons. As you stated, if the BYE is only send in one direction, maybe the dialog is already deleted during the first BYE send out, and depending on the exact timing, its then not send out to the other party. This would be a race condition, the dialog should be only deleted after the second BYE was send out (just guessing right now, have not checked the code). -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/4169#issuecomment-2713814720 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/issues/4169/2713814720@github.com>
miconda left a comment (kamailio/kamailio#4169) Looking at the code, it might have been the case when the response of the first BYE (towards the caller) is received before the second one (towards the callee) is sent out. I pushed a commit on devel version (referenced above), can you try it? -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/4169#issuecomment-2717350609 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/issues/4169/2717350609@github.com>
Mercury109 left a comment (kamailio/kamailio#4169) Thanks for the quick replies, I tested with master and looks good. You're right, the BYE towards the callee is going out 7ms after the loopback BYE sometimes and instantly other times. The two calls compared were identical scenarios so I'm not sure why that happens.  If we can add this to 5.7, that would be great. Thanks again! -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/4169#issuecomment-2718312218 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/issues/4169/2718312218@github.com>
miconda left a comment (kamailio/kamailio#4169) I will check and backport to 5.7 if not breaking other things. Closing as fixed. -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/4169#issuecomment-2748178775 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/issues/4169/2748178775@github.com>
Closed #4169 as completed. -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/4169#event-16956179475 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/issue/4169/issue_event/16956179475@github.com>
pwakano left a comment (kamailio/kamailio#4169) @miconda , sorry to comment on a closed ticket, but I think this change has introduced a problem when closing a dialog via timeout when the caller BYE fails.... My scenario is the following, a webrtc client initiates a call and Kamailio is converting to UDP for the other end. The websocket is closed unexpectedly, then I capture this event and set a dialog timeout of 1s to terminate the call on the UDP end. This used to work on 5.8, but isn't anymore on 6.0.2. Upon checking the logs and changes I noticed this change is likely the cause, because now the dlg_bye_all only sends the BYE to the callee if the BYE to the caller returned 0, but in the webrtc case, it is failing with this error: ``` /usr/sbin/kamailio[2797042]: ERROR: <<null>:0> <core> [core/resolve.c:1773]: sip_hostport2su(): could not resolve hostname: "mywebrtc.invalid" /usr/sbin/kamailio[2797042]: ERROR: <<null>:0> tm [ut.h:302]: uri2dst2(): failed to resolve "mywebrtc.invalid" /usr/sbin/kamailio[2797042]: ERROR: <<null>:0> tm [uac.c:546]: t_uac_prepare(): no socket found /usr/sbin/kamailio[2797042]: ERROR: <<null>:0> dialog [dlg_req_within.c:459]: send_bye(): failed to send the BYE request ``` so then the callee isn't sent a BYE due to this logic change: ``` - ret = send_bye(dlg, DLG_CALLER_LEG, &all_hdrs); - ret |= send_bye(dlg, DLG_CALLEE_LEG, &all_hdrs); + ret = send_bye(dlg, DLG_CALLER_LEG, &all_hdrs, 0); + if(ret == 0) { + ret |= send_bye(dlg, DLG_CALLEE_LEG, &all_hdrs, 1); + } ``` The error to resolve "mywebrtc.invalid" doesn't happen for a normal BYE coming from the UDP end because the NAT handling uses the received/rport instead of resolving the VIA domain but in the timeout case this isn't working... Is there anything I can do on the NAT handling side to overcome this situation or should I open/repopen a ticket in github? -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/4169#issuecomment-3322422832 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/issues/4169/3322422832@github.com>
miconda left a comment (kamailio/kamailio#4169) @pwakano: make a new issue and refer to this one, reviving an old and closed item should be avoided, code in many components may have been changed meanwhile. -- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/4169#issuecomment-3322555174 You are receiving this because you are subscribed to this thread. Message ID: <kamailio/kamailio/issues/4169/3322555174@github.com>
participants (4)
-
Daniel-Constantin Mierla -
Henning Westerholt -
Mercury109 -
pwakano