### Description
Apparently the remapping of 503 to 500 codes in the tm module does also change the to-tag. This behaviour breaks dialogs with yate and therefore calls hang and the 503 remains unacknowledged.
Removing to-tags seems to contradict RFC3261
"12 Dialogs A dialog is identified at each UA with a dialog ID, which consists of a Call-ID value, a local tag **and a remote tag**…"
Due to the bug the UA cannot identify the dialog the 500 belongs to. Therefore the dialog remains open and Kamailio keeps repeating 500 messages.
### Troubleshooting After disabling the 503 to 500 remapping with modparam("tm", "remap_503_500", 0) dialogs get properly terminated .
#### Reproduction
503 to 500 remapping is enabled by default. Inspect the to tags of the incoming 503 and outgoing 500 messages.
#### Debugging Data
Henning added this comment:
Apparently, this is the way the code works:
t_reply.c: if (relayed_code==503 && tm_remap_503_500){ /* replace a final 503 with a 500: * generate a "FAKE" reply and a new to_tag (for easier * debugging)*/
### Possible Solutions
Dont change the to-tag
### Additional Information
kamailio -v version: kamailio 5.2.3 (x86_64/linux) c36229 flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144 MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB poll method support: poll, epoll_lt, epoll_et, sigio_rt, select. id: c36229 compiled on 10:34:54 Jun 13 2019 with gcc 4.8.5
* **Operating System**:
CentOS Linux release 7.6.1810 (Core) 3.10.0-957.12.2.el7.x86_64
Adding another comment from the mailing list:
The SIP code 503 is tricky in the sense that i can indicate either server maintenance or server overload. In both cases it can send Retry-After header and any subsequent requests from same source are ignored for the duration of Retry-After interval. [1].
Additionally RFC3261 and RFC3263 define that transport failures (generally due to fatal ICMP errors in UDP and connection failures in TCP) should be treated as 503 response. [2].
So in all above cases, it is most likely that dialog does not establishes at all and 503 response is treated similar to stateless response. Therefore, a to-tag can be added/replaced before sending it to UAC.
Theoretically, kamailio should check and use to-tag from 503 response when converting it to 500 response and only create new to-tag if it is absent.
References:
[1] https://tools.ietf.org/html/rfc3261#section-21.5.4
[2] https://tools.ietf.org/html/draft-hilt-sip-correction-503-01#section-4
Is anyone planning to work on this one and make a PR?
I think the real bug is that the rewrite happens mid-dialog. I would expect it to only apply on initial INVITE's, not re-INVITE's.
This issue is stale because it has been open 6 weeks with no activity. Remove stale label or comment or this will be closed in 2 weeks.
Closed #2405 as not planned.