[SR-Users] kamailio & redis

Fabian Pignataro fabian.pignataro84 at gmail.com
Mon Jun 27 17:10:54 CEST 2016


Hello Community,

I'm trying to read data (hash) stored in redis database, from kamailio
script.

I read the module documentation ndb_redis:
http://www.kamailio.org/docs/modules/4.4.x/modules/ndb_redis.html#idp26300788
But I'but I don't understand what I'm doing wrong :/

With someone has had experience this?

*My platform:*

*root at kamailio-fts:~# cat /etc/issue*
*Ubuntu 14.04.4 LTS \n \l*

*root at kamailio-fts:~# kamailio  -V*
*version: kamailio 4.4.1 (x86_64/linux) *
*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_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 with gcc 4.8.2*

*My script:*

*modparam("ndb_redis", "server", "name=srvN;addr=127.0.0.1;port=6379;db=1")*
*modparam("ndb_redis", "init_without_redis", 1)*

*if(redis_cmd("srvN", "HMGET usuario:2002 status", "res")) {*
*xlog("L_INFO","array size: $redis(res=>size) - type: $redis(res=>type) -
value: $redis(res=>value[0]) $redis(res=>value[1]) \n");     *
* }*

*The output of syslog (I don't see errors): *

*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: DEBUG: <core>
[db_row.c:95]: db_free_row(): freeing row values at 0x7fc2fd008a30*
*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: DEBUG: <core>
[db_res.c:60]: db_free_rows(): freeing rows at 0x7fc2fd007020*
*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: DEBUG: <core>
[db_res.c:134]: db_free_result(): freeing result set at 0x7fc2fd008a98*
*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: DEBUG: db_postgres
[km_dbase.c:433]: db_postgres_free_query(): PQclear(0xcc9060) result set*
*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: DEBUG: <core>
[socket_info.c:564]: grep_sock_info(): checking if host==us: 13==13 &&
[172.16.20.219] == [172.16.20.219]*
*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: DEBUG: <core>
[socket_info.c:567]: grep_sock_info(): checking if port 5060 (advertise 0)
matches port 5060*
*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: DEBUG: <core>
[select.c:412]: run_select(): Calling SELECT 0x7fc2fcfc09a0*
*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: DEBUG: registrar
[lookup.c:240]: lookup_helper(): contact for [2004] found by address*
*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: INFO: <script>: es
un mensaje y estoy por enviarlo*
*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: INFO: <script>:
array size: 2 - type: 2 - value: <null>*
*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: DEBUG: tm
[t_lookup.c:1312]: t_newtran(): DEBUG: t_newtran: msg id=4 , global msg
id=4 , T on entrance=(nil)*
*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: DEBUG: tm
[t_lookup.c:466]: t_lookup_request(): t_lookup_request: start searching:
hash=36630, isACK=0*
*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: DEBUG: tm
[t_lookup.c:424]: matching_3261(): DEBUG: RFC3261 transaction matching
failed*
*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: DEBUG: tm
[t_lookup.c:648]: t_lookup_request(): DEBUG: t_lookup_request: no
transaction found*
*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: DEBUG: tm
[t_hooks.c:358]: run_reqin_callbacks_internal(): DBG: trans=0x7fc2ed762d08,
callback type 1, id 0 entered*
*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: DEBUG: <core>
[md5utils.c:67]: MD5StringArray(): MD5 calculated:
d79552e0dafc752469a90c3599ba2d42*
*Jun 27 11:48:12 kamailio-fts /usr/sbin/kamailio[31615]: DEBUG: tm
[t_funcs.c:368]: t_relay_to(): SER: new transaction fwd'ed*

It can be seen that $redis(res=>size) & $redis(res=>type) return values,
not so with $redis(res=>value[0]).

*By last, I share de output of redis CLI:*

*127.0.0.1:6379 <http://127.0.0.1:6379>> hget usuario:2002 status *
*"Online" *

Cheers,
Fabián -

-- 
Ing. Fabián Pignataro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20160627/f879cc6c/attachment.html>


More information about the sr-users mailing list