Origination SIP CANCEL not handled properly

Hello, when i send an invite and soon after i send a cancel the flow is not correct.
I make an example:
origination invite → sems → termination
origination cancel → sems-> termination
sems send a 200 0k and then a 487 request terminated to the origination,
from the termination sems receives only 200 and close the session and the cdr, subsequent 487 from termination is not handled properly.

Sems version 1.12.30core81

Partial logs from termination to SEMS

[332338/332400] [./core/sip/udp_trsp.cpp:358] DEBUG: vv M [|] u recvd msg via UDP from TERMINATION vv
--++--
SIP/2.0 200 canceling


--++--
 [332338/332400] [./core/sip/parse_via.cpp:548] DEBUG: parsed branch: z9hG4bK6IZ52aje
 [332338/332400] [./core/sip/parse_via.cpp:571] DEBUG: has_rport: 1
 [332338/332400] [./core/sip/trans_layer.cpp:1944] DEBUG: Reply matched an existing transaction
 [332338/332400] [./core/sip/trans_layer.cpp:2006] DEBUG: update_uac_reply(reply code = 200, trans=0x7f967c02a6a0)
 [332338/332400] [./core/sip/sip_trans.cpp:201] DEBUG: Clearing old timer of type E (timer=0x7f967c02a7e0)(trans=0x7f967c02a6a0)
 [332338/332400] [./core/sip/sip_trans.cpp:201] DEBUG: Clearing old timer of type F (timer=0x7f967c02a820)(trans=0x7f967c02a6a0)
 [332338/332400] [./core/sip/sip_trans.cpp:259] DEBUG: New timer of type K at time=4151 (repeated=0)(trans=0x7f967c02a6a0)
 [332338/332390] [./src/cdr/CdrWriter.cpp:805] DEBUG: writecdr(): process cdr 0x7f9684008b20
 [332338/332400] [./core/sip/udp_trsp.cpp:358] DEBUG: vv M [|] u recvd msg via UDP from TERMINATION vv
--++--
SIP/2.0 487 Request terminated


--++--
 [332338/332400] [./core/sip/parse_via.cpp:548] DEBUG: parsed branch: z9hG4bK6IZ52aje
 [332338/332400] [./core/sip/parse_via.cpp:571] DEBUG: has_rport: 1
 [332338/332400] [./core/sip/trans_layer.cpp:1972] DEBUG: Reply did NOT match any existing transaction...
 [332338/332400] [./core/sip/trans_layer.cpp:1973] DEBUG: reply code = 487
 [332338/332390] [./src/cdr/CdrWriter.cpp:638] DEBUG: 1 records were written into master
 [332338/332390] [./src/cdr/Cdr.cpp:148] DEBUG: ~Cdr[0x7f9684008b20]()
 [332338/332390] [./src/cdr/CdrWriter.cpp:505] DEBUG: 1 records are removed from queue
 [332338/332400] [./core/sip/udp_trsp.cpp:358] DEBUG: vv M [|] u recvd msg via UDP from TERMINATION vv
--++--
SIP/2.0 487 Request terminated

also with version 1.12.32core84 same exact issue

could you provide full pcap trace. Also what “proper handling” of 487 you expect?

SEMS need to manage 487 sent by termination and has to respond with an ack, if that’s not happening the termination will continue to send multiple times 487 responses. Basically might be like the signaling between the origination and SEMS after the CANCEL you can see on the screenshot.

on the pcap last signaling is not recorded because as you can see from the debug SEMS reject this subsequent responses but it should be like in picture (sorry I don’t have the right sketching tools)

As I understand this images created by wireshark from pcap file stored by SEMS. Could you save pcap using tcpdump and share it, because I think this 487 response is not valid. So I would see this full flow, where 487 retransmits are visible

i send the pcap on pm, in the meantime here there is the screenshot from pcap via tcpdump

I upload also an example using kamailio as sip outbound proxy, signaling seems correct until kamailio sends 487 to sems

Hello,

Thank you for the so useful and detailed report.
Untimely SIP dialog drop on the leg termination.

the bug was introduced in libsems1 1.81.1 by the commit intended to fix sessions stuck on wrong SIP signalling cases.

fixed in libsems1 1.85.0, sems-modules-yeti 1.12.33core85

thank you very much for your reply!
I’ve just updated to latest release and made a test, it’s now working perfectly, issue is solved now.
Thank you!

sorry, after updating i’ve an issue with module g729-bcg, i’ve already installed sems-modules-g729-bcg

[511365/511365] [AmPlugIn.cpp:697] WARNING: codec 60 does not provide bytes2samples function
 [511365/511365] [AmPlugIn.cpp:700] WARNING: codec 60 does not provide samples2bytes function
 [511365/511365] [AmPlugIn.cpp:266] ERROR: AmPlugIn::loadPlugIn: /usr/lib/sems/plug-in/g729bcg.so: /usr/lib/sems/plug-in/g729bcg.so: undefined symbol: _Z13bcg729DecoderP40bcg729DecoderChannelContextStruct_structPKhhhhhPs
 [511365/511365] [AmPlugIn.cpp:189] ERROR: while loading plug-in '/usr/lib/sems/plug-in/g729bcg.so'

upgrade sems-modules-g729-bcg to the version 0.0.4

ok, now everything is working, thanks a lot!