Function "tcp_get_conid" from tcpops module does not write the conid into target variable
I followed the documentation on https://www.kamailio.org/docs/modules/devel/modules/tcpops.html#tcpops.f.tcp...
And with debug enabled, you see the connection is found:
`Jun 30 14:13:47 kamailio-dev-2 /usr/sbin/kamailio[121285]: DEBUG: <core> [core/tcp_main.c:1670]: _tcpconn_find(): found connection by peer address (id: 14)`
But the given variable $var(conid) is always empty.
After a lookup("location") the code is like:
``` if(tcp_get_conid("$dd:$dp", "$var(conid)")) { xlog("connection id is: $var(conid)\n"); } ``` But the given variable $var(conid) is always empty.
Version used: kamailio 5.3.5 (x86_64/linux)
The code looks ok for setting the variable. Can you provide all logs printed by kamailio with debug=3 in config, from the moment of receiving the sip message till its end of processing, when this case is reproduce?
To reproduce, i installed a new Kamailio 5.3.5 from http://deb.kamailio.org/kamailio53 on a fresh debian 10 vm and only added: ``` --- kamailio.cfg 2020-06-22 14:21:22.000000000 +0200 +++ /home/kris/kamailio.cfg 2020-07-01 13:07:15.476661500 +0200 @@ -19,7 +19,7 @@ # Several features can be enabled using '#!define WITH_FEATURE' directives: # # *** To run in debug mode: -# - define WITH_DEBUG +#!define WITH_DEBUG # # *** To enable mysql: # - define WITH_MYSQL @@ -248,6 +248,7 @@ loadmodule "cfg_rpc.so" loadmodule "acc.so" loadmodule "counters.so" +loadmodule "tcpops.so"
#!ifdef WITH_AUTH loadmodule "auth.so" @@ -699,6 +700,11 @@ setflag(FLT_ACCMISSED); }
+ xlog("L_INFO", "Contact found for user:$rU at $rd:$rp \n"); + if(tcp_get_conid("$rd:$rp", "$var(conid)")) { + xlog("L_INFO", "connection id is: $var(conid)\n"); + } + route(RELAY); exit; } root@ ``` And $var(conid) is empty.
debug 3 lof file: [debug3-log.txt](https://github.com/kamailio/kamailio/files/4857454/debug3-log.txt)
Then called a uac which is registered via TCP
Strange, looked further in the code and seems all ok, no error messages -- I will try to troubleshoot when I get a chance to test with tcp phones. Meanwhile, can you test the following variant and see what is printed:
``` xlog("L_INFO", "Contact found for user:$rU at $rd:$rp \n"); if(tcp_get_conid("$rd:$rp", "$var(conid)")) { xlog("L_INFO", "connection id is: $var(conid)\n"); $var(conidx) = 10 + $var(conid); xlog("L_INFO", "connection id added with 10 is: $var(conidx)\n"); } ```
Want to see if it is set initially to empty string or an integer value that is not properly converted to string in the xlog. This time you can paste here the three log messages printed from script along with the one from the source code which looks like:
``` Jul 1 13:10:20 debian10 kamailio[5445]: 12(5459) DEBUG: {1 1 INVITE 1c6ffc5e1998-0pcb8iktd8rw@snomSoft} <core> [core/tcp_main.c:1670]: _tcpconn_find(): found connection by peer address (id: 1) ```
``` Jul 1 14:49:27 debian10 kamailio[5644]: 9(5655) INFO: {1 1 INVITE 5786fc5eb54a-4wh0mpzuxwx6@snomSoft} <script>: Contact found for user:101 at 192.168.43.89:60601 Jul 1 14:49:27 debian10 kamailio[5644]: 9(5655) exec: {1 1 INVITE 5786fc5eb54a-4wh0mpzuxwx6@snomSoft} *** cfgtrace:request_route=[LOCATION] c=[/etc/kamailio/kamailio.cfg] l=710 a=16 n=if Jul 1 14:49:27 debian10 kamailio[5644]: 9(5655) exec: {1 1 INVITE 5786fc5eb54a-4wh0mpzuxwx6@snomSoft} *** cfgtrace:request_route=[LOCATION] c=[/etc/kamailio/kamailio.cfg] l=704 a=26 n=tcp_get_conid Jul 1 14:49:27 debian10 kamailio[5644]: 9(5655) DEBUG: {1 1 INVITE 5786fc5eb54a-4wh0mpzuxwx6@snomSoft} <core> [core/tcp_main.c:1670]: _tcpconn_find(): found connection by peer address (id: 1) Jul 1 14:49:27 debian10 kamailio[5644]: 9(5655) exec: {1 1 INVITE 5786fc5eb54a-4wh0mpzuxwx6@snomSoft} *** cfgtrace:request_route=[LOCATION] c=[/etc/kamailio/kamailio.cfg] l=705 a=26 n=xlog Jul 1 14:49:27 debian10 kamailio[5644]: 9(5655) INFO: {1 1 INVITE 5786fc5eb54a-4wh0mpzuxwx6@snomSoft} <script>: connection id is: Jul 1 14:49:27 debian10 kamailio[5644]: 9(5655) exec: {1 1 INVITE 5786fc5eb54a-4wh0mpzuxwx6@snomSoft} *** cfgtrace:request_route=[LOCATION] c=[/etc/kamailio/kamailio.cfg] l=706 a=63 n=assign Jul 1 14:49:27 debian10 kamailio[5644]: 9(5655) exec: {1 1 INVITE 5786fc5eb54a-4wh0mpzuxwx6@snomSoft} *** cfgtrace:request_route=[LOCATION] c=[/etc/kamailio/kamailio.cfg] l=707 a=26 n=xlog Jul 1 14:49:27 debian10 kamailio[5644]: 9(5655) INFO: {1 1 INVITE 5786fc5eb54a-4wh0mpzuxwx6@snomSoft} <script>: connection id added with 10 is: 10 ```
Issue was fixed for me with: https://github.com/kamailio/kamailio/pull/2386
Closed #2382.
fixed with https://github.com/kamailio/kamailio/commit/fbb4312f1b2ebf6793408241d56bfc2d...