<!--
Kamailio Project uses GitHub Issues only for bugs in the code or feature requests.
If you have questions about using Kamailio or related to its configuration file,
ask on sr-users mailing list:
* http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
If you have questions about developing extensions to Kamailio or its existing
C code, ask on sr-dev mailing list
* http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
Please try to fill this template as much as possible for any issue. It helps the
developers to troubleshoot the issue.
If you submit a feature request (or enhancement), you can delete the text of
the template and only add the description of what you would like to be added.
If there is no content to be filled in a section, the entire section can be removed.
You can delete the comments from the template sections when filling.
You can delete next line and everything above before submitting (it is a comment).
-->
### Description
<!--
Explain what you did, what you expected to happen, and what actually happened.
-->
### Troubleshooting
#### Reproduction
we have an issue with our Kamailio.
This configuration is multi-homed, we have two network interfaces, one on a private network and on the public Internet. Kamailio is configured to listen on port 5060 and 5066 on both interfaces. We register two users Alice and Bob on the public Internet using port 5066. Both users are behind a NAT and we capture the SIP exchange on the proxy server.
We have set the parameter mhomed=1
![image](https://user-images.githubusercontent.com/16304253/35796442-e642d466-0a5c-11e8-846f-a538e3185a69.png)
The ACK packet gets relayed with the wrong source port. Then the NAT rejects the packet and the call cannot be established.
Also, if we set mhomed=0 it works BUT we are not sure that multi homed is handled correctly.
the issue seems to be located in the RR module and the loose_route() function.
In the after_loose() function in loose.c, the function set_force_socket() is called only if a DOUBLE route is mentioned in the route set of the ACK message
But when both users are using 5066 as proxy port, we get only ONE route for the proxy in the route set (and to us it is OK). In this case, we get a trace:
"No next URI found"
and the code exits. Later in the message processing, when t_relay() is called, the forward_request() selects the first socket defined in our configuration instead.
At this point, we can't presume what socket we be select. We believe that it is a software bug and that after_loose() should force the send_socket even though we have only one route in the route set
#### Debugging Data
<!--
If you got a core dump, use gdb to extract troubleshooting data - full backtrace,
local variables and the list of the code at the issue location.
gdb /path/to/kamailio /path/to/corefile
bt full
info locals
list
If you are familiar with gdb, feel free to attach more of what you consider to
be relevant.
-->
```
(paste your debugging data here)
```
#### Log Messages
<!--
Check the syslog file and if there are relevant log messages printed by Kamailio, add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site).
-->
```
(paste your log messages here)
```
#### SIP Traffic
<!--
If the issue is exposed by processing specific SIP messages, grab them with ngrep or save in a pcap file, then add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site).
-->
```
(paste your sip traffic here)
```
### Possible Solutions
Adding the process of set_force_socket in case we have one route and only.
L.808 if (res > 0) { /* No next route found */
LM_DBG("No next URI found\n");
> if (!use_ob) {
> if ((si = grep_sock_info( &puri.host, puri.port_no?puri.port_no:proto_default_port(puri.proto), puri.proto)) != 0) {
> set_force_socket(_m, si);
> } else if ((si = grep_sock_info( &puri.host, puri.port_no, puri.proto)) != 0) {
> set_force_socket(_m, si);
> } else {
> if (enable_socket_mismatch_warning) {
> LM_WARN("no socket found to match second RR (%.*s)\n",
> rt->nameaddr.uri.len, ZSW(rt->nameaddr.uri.s));
> if(!is_myself(&puri)) {
> LM_WARN("second RR uri is not myself (%.*s)\n",
> rt->nameaddr.uri.len, ZSW(rt->nameaddr.uri.s));
> }
> }
> }
> }
status = (preloaded ? NOT_RR_DRIVEN : RR_DRIVEN);
goto done;
}
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
(paste your output here)
```
* **Operating System**:
<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `uname -a`)
-->
```
(paste your output here)
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1428
<!-- Kamailio Pull Request Template -->
<!--
IMPORTANT:
- for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
- pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
- backports to stable branches must be done with 'git cherry-pick -x ...'
- code is contributed under BSD for core and main components (tm, sl, auth, tls)
- code is contributed GPLv2 or a compatible license for the other components
- GPL code is contributed with OpenSSL licensing exception
-->
#### Pre-Submission Checklist
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, ...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [x] No commits to README files for modules (changes must be done to docbook files
in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
<!-- Go over all points below, and after creating the PR, tick the checkboxes that apply -->
- [ ] PR should be backported to stable branches
- [x] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description
This commit is introducing JSON format for ACC events.
2 way to output the ACC events are proposed/implemented (syslog and mqueue)
The option to use db_flastore was considered and found less attractive, mainly because the DB abstraction layer is not making much sense, example reformatting the data many times ...
and other outputs could benefit from JSON format.
1- syslog (directly from the module, because it may be valuable to run Kamailio using runit or in docker and not "daemionizing" it anymore while still using syslog for acc events)
2- mqueue this way you may be able to control the acc event from Kamailio routing script, and example is provided using the http_client module to publish to NSQD
This seemed to be the best approach to remain as compatible as possible with the ACC module and benefit from it, while introducing the JSON format.
Many parameters are reused like time_mode, log_extra, log_facility, it seemed like reusing was making sense, this may be questionable.
If jansson or mqueue is not available or loaded the module will still build and run disabling the extra features
----------------------------------------------------------
#### Usage example
where we use mqueue and process acc events in other worker processes.
example also inluded in the doc
```
# example using json_mqueue/http_client to publish to NSQD
max_while_loops=100000
modparam("mqueue", "mqueue", "name=acc_events;size=100000")
modparam("acc", "json_mqueue", "acc_events")
modparam("acc", "json_flag", 2)
modparam("acc", "log_extra", "caller_ip_port=$avp(caller_ip_port);")
modparam("rtimer", "timer", "name=nsqt;interval=1;mode=1;")
modparam("rtimer", "exec", "timer=nsqt;route=RUN_CDR_PUBLISH")
modparam("http_client", "keep_connections", 1)
modparam("http_client", "httpcon", "nsqd=>http://localhost:4151/pub?topic=acc")
route[RUN_CDR_PUBLISH] {
$var(count) = 0;
while (mq_fetch("acc_events")) {
$var(q_size) = mq_size("acc_events");
$var(count) = $var(count) + 1;
xinfo("[RUN_CDR_PUBLISH][$var(q_size)][$var(count)][$mqk(acc_events)][$mqv(acc_events)]\n");
$var(res) = http_connect("nsqd", "", "application/json", $mqv(acc_events), "$var(nsq_res)");
if ($var(res) != "200") {
mq_add("acc_events", "acc_key", "$mqv(acc_events)");
return;
}
}
if ($var(count) > 0 ) {
xinfo("[RUN_CDR_PUBLISH]done count[$var(count)]\n");
}
}
```
#### Load testing
Load tests where conducted with both json_syslog and json_mqueue/http to NSQD, latency was very stable it was high because the test server used was on West coast
California >> New-Jersey >> California
![image](https://user-images.githubusercontent.com/3736014/36117214-a6ebcebc-0fed-11e8-928c-9ff9321bef86.png)
average message/response latency graph in ms/sec
----------------------------------------------------------
Using voip_perf to send SIP compliant traffic (INVITE < 100 < 180 < 200 > ACK || BYE < 200)
7M SIP messages calls sent > 800/sec
https://github.com/jchavanton/voip_perf
```
Total 1000000 INVITE calls sent in 1037082 ms at rate of 819/sec
Total 1000000 responses received in 1037881 ms at rate of 818/sec:
Detailed responses received:
- 200 responses: 1000000 (OK)
------
TOTAL responses: 1000000 (rate=818/sec)
```
All the ACC events where queued in NSQD and written to SYSLOG without introducing delay.
```
curl -v http://127.0.0.1:4151/stats
nsqd v1.0.0-compat (built w/go1.8)
start_time 2018-02-12T17:10:58Z
uptime 33m4.181861175s
Health: OK
[acc ] depth: 3000004 be-depth: 2990004 msgs: 3000004 e2e%:
```
```
wc -l /var/log/json_acc.log
3000004 /var/log/json_acc.log
```
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/1437
-- Commit Summary --
* acc: new json format with outputs to mqueue or syslog
-- File Changes --
M src/modules/acc/Makefile (12)
M src/modules/acc/acc.c (109)
M src/modules/acc/acc.h (1)
M src/modules/acc/acc_logic.c (27)
M src/modules/acc/acc_mod.c (25)
M src/modules/acc/acc_mod.h (3)
M src/modules/acc/doc/acc.xml (10)
M src/modules/acc/doc/acc_admin.xml (121)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/1437.patchhttps://github.com/kamailio/kamailio/pull/1437.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1437
Module: kamailio
Branch: master
Commit: 53e746b5c527fa542e4b2b7353af5a3b4042d7d2
URL: https://github.com/kamailio/kamailio/commit/53e746b5c527fa542e4b2b7353af5a3…
Author: Andreas Granig <agranig(a)sipwise.com>
Committer: Andreas Granig <agranig(a)sipwise.com>
Date: 2018-02-08T15:54:02+01:00
db_redis: Implement db_redis generic db driver
This module implements a generic db driver for kamailio. It
requires a "schema" and "key" definition of "tables" and corresponding
keys for redis in the kamailio config file, otherwise it's supposed to
work with every module.
Implemented methods are query (w/o order-by), insert, update, delete.
Tested with usrloc and acc.
---
Added: src/modules/db_redis/Makefile
Added: src/modules/db_redis/README
Added: src/modules/db_redis/db_redis_mod.c
Added: src/modules/db_redis/db_redis_mod.h
Added: src/modules/db_redis/doc/Makefile
Added: src/modules/db_redis/doc/db_redis.xml
Added: src/modules/db_redis/doc/db_redis_admin.xml
Added: src/modules/db_redis/redis_connection.c
Added: src/modules/db_redis/redis_connection.h
Added: src/modules/db_redis/redis_dbase.c
Added: src/modules/db_redis/redis_dbase.h
Added: src/modules/db_redis/redis_table.c
Added: src/modules/db_redis/redis_table.h
Modified: src/Makefile.groups
---
Diff: https://github.com/kamailio/kamailio/commit/53e746b5c527fa542e4b2b7353af5a3…
Patch: https://github.com/kamailio/kamailio/commit/53e746b5c527fa542e4b2b7353af5a3…