Hello,

the uac_replace_from()/_to() rely on the UA preserving the From/To headers to be able to properly restore the values when used with the rr (record-route) mechanism.

If you can't ensure that the UA preserve these headers, then you can:

1) configure uac module to use dialog module for update/restore operations of From/To header

2) do not restore the From/To -- the restore is done for the old devices that use full Form/To headers for matching transactions and dialogs, instead of From-tag and To-tag parameters, so practically the restore is needed when the UA is not implementing RFC 3261, but older SIP specs. What I typically do when I have only RFC3261 devices is to replace From/To headers with what I need in the initial INVITE and for the rest of the requests within the dialog I replace them with anonymous@anonymous.invalid.

Cheers,
Daniel


On 24.06.18 10:21, Kjeld Flarup wrote:
I have a system where the calls is not disconnected properly.

I get this error in syslog when receiving BYE:

Jun 24 08:23:54 scantronpbx /usr/local/sbin/kamailio[31588]: WARNING: uac [replace.c:645]: restore_uri(): invalid char found in the new uri at pos 30 (#012) [sip:004540294149@127.0.0.1:507#01257441;transport=TCP;ob]
Jun 24 08:23:54 scantronpbx /usr/local/sbin/kamailio[31588]: WARNING: uac [replace.c:647]: restore_uri(): this can happen when URI values are altered by end points - skipping the update
Jun 24 08:23:54 scantronpbx /usr/local/sbin/kamailio[31588]: WARNING: uac [replace.c:645]: restore_uri(): invalid char found in the new uri at pos 30 (#012) [sip:004540294149@127.0.0.1:507#01257441;transport=TCP;ob]
Jun 24 08:23:54 scantronpbx /usr/local/sbin/kamailio[31588]: WARNING: uac [replace.c:647]: restore_uri(): this can happen when URI values are altered by end points - skipping the update
Jun 24 08:24:11 scantronpbx /usr/local/sbin/kamailio[31588]: WARNING: uac [replace.c:645]: restore_uri(): invalid char found in the new uri at pos 30 (#012) [sip:004540294149@127.0.0.1:507#01257441;transport=TCP;ob]
Jun 24 08:24:11 scantronpbx /usr/local/sbin/kamailio[31588]: WARNING: uac [replace.c:647]: restore_uri(): this can happen when URI values are altered by end points - skipping the update

Kamailio receives this From header:
f: <sip:004540294149@194.255.22.44>;tag=e042cfe1-40f7-410d-95fd-e5bb4f8976d7;transport=TCP;ob

And passes this on, where it is obvious that '%' may give a problem
f: <sip:0001@192.168.2%:>;tag=e042cfe1-40f7-410d-95fd-e5bb4f8976d7;transport=TCP;ob

The RR headers send forward with INVITE looks like this:
Record-Route: <sip:127.0.0.1:5069;r2=on;lr=on;ftag=MYEMZIUn-UWwH-R7g9CktpyvOn1ZFuZu;vsf=AAAAAEUAcAB5AxcDGAkYCgALLjEwMQ--;did=2f6.6cc;vst=AAAAAAAABAR0AQsLGgACAW4DHA4uMC4wLjE6NTA3MA-->
Record-Route: <sip:192.168.2.9:5069;r2=on;lr=on;ftag=MYEMZIUn-UWwH-R7g9CktpyvOn1ZFuZu;vsf=AAAAAEUAcAB5AxcDGAkYCgALLjEwMQ--;did=2f6.6cc;vst=AAAAAAAABAR0AQsLGgACAW4DHA4uMC4wLjE6NTA3MA-->

And received on BYE
Route: <sip:127.0.0.1:5069;lr;r2=on;ftag=MYEMZIUn-UWwH-R7g9CktpyvOn1ZFuZu;vsf=AAAAAEUAcAB5AxcDGAkYCgALLjEwMQ--;did=2f6.6cc;vst=AAAAAAAABAR0AQsLGgACAW4DHA4uMC4wLjE6NTA3MA-->
Route: <sip:192.168.2.9:5069;lr;r2=on;ftag=MYEMZIUn-UWwH-R7g9CktpyvOn1ZFuZu;vsf=AAAAAEUAcAB5AxcDGAkYCgALLjEwMQ--;did=2f6.6cc;vst=AAAAAAAABAR0AQsLGgACAW4DHA4uMC4wLjE6NTA3MA-->

RR does not seem to be the problem as mentioned here: https://opensips.org/pipermail/users/2010-October/014999.html

I have attached a pcap file with the full trace. The error appears in frame 101


The setup is a bit complex, as I have 8 Kamailio's running, where 6 is identical.

The first Kamailio is on port 5069, which receives a call from a door phone. It then branches the call to registrations or GSM targets, which is handled by the other Kamailio's
Thus 5069 is only doing a lookup in a database and branching, plus it handles rtpengine.

I first saw the error on version 4.4, and now I replicated it on 5.1.4. My hardware is a Raspberry Pi.

/usr/local/sbin/kamailio -v
version: kamailio 5.1.4 (arm6/linux)
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, 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-NOSMP, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, 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 23:45:36 Jun 19 2018 with gcc 4.9.2



_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference -- www.kamailioworld.com