As guessed before, you are using forward() in your config, which does stateless forwarding, next is the part of the config showing it:
``` ... request_route {
# per request initial checks route(REQINIT);
# NAT detection route(NATDETECT); t_check_trans(); if ( method=="INVITE" ) { ds_select_dst("1","4"); sl_send_reply("100","Trying"); forward(); exit(); } ... ```
You have to use t_relay() instead of forward() for stateful routing, if you want to work on top of default kamailio.cfg. Otherwise, you have to add a logic to ensure that CANCEL is sent to the same destination as INVITE.
Also, the place in config where you do the routing for INVITE is not really a good one, re-INVITEs being misrouted.
Anyhow, this is not an issue of kamailio code, but the configuration file. You have to use sr-users@lists.kamailio.org mailing list for sorting out issue with kamailio.cfg.
Closing this one.