Hello, we have faced an issue which appears when TOPOH module is enabled, call is made from WebRTC client, then transferred by callee. 
We have WebRTC client behind load balancer. We make call to softphone from WebRTC, call from softphone is transferred to external number using Asterisk.
When call is hanged up on external number side, it doesn't hangs up on WebRTC client side.
If TOPOH is not enabled, this issue doesn't occur.

We have the following TOPOH-related sections of kamailio.cfg:

<...>
#!ifdef WITH_TOPOH
loadmodule "topoh.so"
#!endif
<...>

<...>
#!ifdef WITH_TOPOH
modparam("topoh", "mask_key", "xxxxxxxxxxxxxxxx")
modparam("topoh", "mask_ip", "10.0.0.1")
modparam("topoh", "mask_callid", 0)
modparam("topoh", "sanity_checks", 1)
modparam("topoh", "uparam_prefix", "")
modparam("topoh", "vparam_prefix", "")
modparam("topoh", "callid_prefix", "1337")
#!endif
<...>

<...>
#!ifdef WITH_DIALOG
modparam("dialog", "db_url", DBURL)
modparam("dialog", "db_mode", 1)
modparam("dialog", "db_fetch_rows", 800)
modparam("dialog", "track_cseq_updates", 1)
modparam("dialog", "ka_interval", 30)
modparam("dialog", "ka_timer", 30)
modparam("dialog", "send_bye", 0)
modparam("dialog", "dlg_filter_mode", 1)
#!ifdef WITH_TOPOH
modparam("dialog", "lreq_callee_headers", "TH: dlh\r\n")
#!endif
#!endif
<...>

<...>
#!ifdef WITH_DISPATCHER
event_route[dispatcher:dst-up] {
           sql_query("ds_dburl", "select description from dispatcher where destination='$ru'", "ds_dbresult");
           xlog("L_WARN", "Destination up: $ru, found name: $dbr(ds_dbresult=>[0,0])\n");
           prom_gauge_set("trunk_reachability", "1", "$ru", "$dbr(ds_dbresult=>[0,0])");
           }

           event_route[dispatcher:dst-down] {
                       sql_query("ds_dburl", "select description from dispatcher where destination='$ru'", "ds_dbresult");
                       xlog("L_WARN", "Destination down: $ru, found name: $dbr(ds_dbresult=>[0,0])\n");
                       prom_gauge_set("trunk_reachability", "0", "$ru", "$dbr(ds_dbresult=>[0,0])");
                       }
                       #!endif

                       #!ifdef WITH_TOPOH
                       event_route[topoh:msg-sending] {
if(is_reply() and $rs=="302") {
drop;
}
}
#!endif

(can provide the full config, if needed)

We are receiving the following errors:

On transfer:
https://pastebin.com/H3FQ4Kpj

On hangup from external number side:
https://pastebin.com/wgfRzGbd

On hangup from WebRTC client side:
https://pastebin.com/sE0yhBae

There are also differences in SIP traffic when TOPOH is disabled and when it is enabled. With TOPOH enabled, apparently, ACK from Asterisk is not reaching kamailio:

asterisk INVITE -> kamailio -> WebRTC
WebRTC 200 -> kamailio -> asterisk
asterisk ACK -> kamailio -> -> ->

(SIP flows attached - topoh_on.csv, topoh_off.csv)


kamailio -v
version: kamailio 5.6.1 (x86_64/linux)
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, 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_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
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: unknown
compiled on 09:11:15 Nov 15 2022 with gcc 9.3.0

We have dockerized kamailio running on Ubuntu 16.04.3 LTS
Docker version 18.03.1-ce, build 9ee9f40

Please advise where to start looking.