Hi all,
I am trying to place Kamailio between several SIP services which are differentiated by port and by the type of message they handle. To be concrete, here are the services:
Originator:
- reachable on port 5060
- originates all traffic to the services
Service A:
- reachable on port 5061
- handles REGISTER
Service B:
- reachable on port 5062
- handles INVITE
Service C:
- reachable on port 5063
- handles MESSAGE
The services, originator and Kamailio instance may all be run on the same IP or may be split onto different addresses. Previously, the originator needed to know the address and port of each service. Now I want to make Kamailio responsible for that task so it can be done more intelligently.
To start though I simply want to get traffic flowing between the services and this is where I’m struggling to climb the learning curve. In my test setup the originator and all services are on the same IP with only Kamailio running on a different IP.
Address 1 Address 2
========================
Originator <--> Kamailio:6060
|
|
Service A <-------> |
Service B <-------> |
Service C <-------> |
My first attempt at the logic looks like this:
# HOST DEFINITIONS
#!substdef "/HOST_ORIGINATOR/192.168.86.110/"
#!substdef "/HOST_REGISTER/192.168.86.110/“
#!substdef "/HOST_INVITE/192.168.86.110/"
#!substdef "/HOST_MESSAGE/192.168.86.110/"
# PORT DEFINITIONS
#!substdef “/PORT_ORIGINATOR/5060/"
#!substdef "/PORT_REGISTER/5061/“
#!substdef "/PORT_INVITE/5062/"
#!substdef "/PORT_MESSAGE/5063/"
# ROUTE LOGIC
route {
# ORIGINATOR sent us something
if ( $(ct{nameaddr.uri}{uri.port}) == HOST_ORIGINATOR ) {
xlog("L_INFO", "ORIGINATOR: sent $rm\n”);
if (is_method("REGISTER")) {
$du = "sip: HOST_REGISTER:PORT_REGISTER";
xlog("L_INFO", "ORIGINATOR -> REGISTER: Destination URI is now $du\n");
t_relay();
exit;
}
}
…
#### END SNIPPET ####
My very newbie questions are:
- Am I even on the right track here? I understand that t_relay() establishes a stateful dialog handler between the originator and register services.
- Can I accomplish this bi-directional path statelessly with forward()?
- Do I need to add logic to handle the messages from the REGISTER service back to ORIGINATOR?
This config currently fails because of "no corresponding socket found” when the relay triggers. I believe this is because I’m running the Kamailio instance in a Docker container so my first step today is to set up a native install.
I also looked at the dispatcher module which seems very close to what I want to do. Maybe that’s a more natural way to go?
Anyway, apologies for the lengthy explanation. I hope it is at least clear what I intend to do. I will gladly research and do trial and error to solve this but need to know I’m going down roughly the right path. I’m not sure what I should even be googling even of the time :-)
Thanks as always for your time and the great software!
Regards,
-Michael
Hello,
I'm setting up a Kamailio instance behind a TCP load balancer (with proxy
protocol and NAT routing: meaning Kam stays in the flow all the time).
I've managed to get working almost everything we need for our service,
except for one thing, and that is for Kam to use existing connections for
subsequent transactions:
Following this example:
[image: image.png]
EXT & INT represent the external and internal interface of a LB between the
UAC and Kamailio, using TLS on both legs and proxy protocol.
Transaction 1: INVITE, 100, 180, 183, 200 OK
UAC 1.1.1.1:1111 -> 2.2.2.2:443 (EXT) 3.3.3.3:3333 (INT) -> 7.7.7.7:5060
(Kamailio)
Transaction 2: ACK
UAC 1.1.1.1:1112 -> 2.2.2.2:443 (EXT) 4.4.4.4:4444 (INT) -> 7.7.7.7:5060
(Kamailio)
Transaction 3: BYE
Kam 7.7.7.7:5060 -> 3.3.3.3:3333 (INT) 2.2.2.2:443 (EXT) -> 1.1.1.1:1111 UAC
My problem is with Transaction 3. In this case the BYE is originated by the
callee, and Kam has to send it to the caller. As the TCP load balancer is
between Kam and the UAC, Kam has to send it to the LB so then the LB can
forward it back to the UAC. This works well for msgs that belong to the
same transaction (INVITE, 100, 180, 183, 200 OK) but it fails when they
don't belong to the same transaction.
Thanks to the newly added $tcp(c_si) and $tcp(c_sp) pseudovars, I can save
the internal IP:Port of the LB, so I can send stuff later to it, my problem
is that Kam doesn't seem to allow this?
On the original INVITE, I use the following to save where I have to reach
the UAC:
add_contact_alias("$tcp(c_si)", "$tcp(c_sp)", "tls");
Then, handle_ruri_alias() will take care of setting $du to the correct
(internal LB) IP:Port so I can reach the UAC, this works.
My problem is that Kamailio doesn't identify that there is a valid existing
TLS connection still up (from the INVITE), and tries to create a new one
(and this obviously doesn't gives all sorts of problems).
So when I run handle_ruri_alias(), and $du is set to 3.3.3.3:3333 (from the
example above), instead of using the existing connection, Kamailio tries to
create a new one.
I have a log statement right before with the result of tcp_conid_state(1)
(the connid is 1 for this connection) and the $rc is 1 (Connection is OK),
but when I tell Kamailio it has to use it I get this in the logs:
DEBUG: {1 11726467 BYE gqR1qqNK8B} <core> [core\/tcp_main.c:2060]:
tcp_send(): no open tcp connection found, opening new one"}
And then the problems begin...
I have tried playing around with:
tcp_reuse_port
tcp_connection_match
But no luck..!
I also thought it could be a problem of the connection being created on one
worker, and a different worker handling BYE transaction, so tested with
children=1 and tcp_children=1, but still same problem.
A more detailed log:
In blue my log statement checking for the status of conid "1", in red Kam
not being able to find it, although it exists (as validated
by tcp_conid_state(), and even in netstat I can see the connection
established). In this log, 35.191.0.66:60271 would be the equivalent of
3.3.3.3:3333 and 104.175.176.242:28157 would be 1.1.1.1:1111 from the
example above.
...
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} <core>
[core\/tcp_main.c:1657]: _tcpconn_find(): found connection by id: 1"}
"message":" NOTICE: {1 11727734 BYE 5-LX4GdI9X} <script>: JOEL TEST New
request - M=BYE TCP STATUS:1 ID=5-LX4GdI9X"}
...
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} nathelper
[nathelper.c:1144]: handle_ruri_alias(): setting dst_uri to
<sip:35.191.0.66:60271;transport=tls>"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} nathelper
[nathelper.c:1166]: handle_ruri_alias(): rewriting r-uri to
<sip:linphone@104.175.176.242:28157;transport=tls>"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} tm [t_lookup.c:1328]:
t_newtran(): msg (0x7f3c884259d0) id=534\/18664 global id=532\/18664 T
start=0xffffffffffffffff"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} tm [t_lookup.c:497]:
t_lookup_request(): start searching: hash=63496, isACK=0"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} tm [t_lookup.c:455]:
matching_3261(): RFC3261 transaction matching failed - via branch
[z9hG4bK808f.eee2444f92a02cb33e1b7a21f20bc6bb.0]"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} tm [t_lookup.c:675]:
t_lookup_request(): no transaction found"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} tm [t_hooks.c:336]:
run_reqin_callbacks_internal(): trans=0x7f3c83b8c598, callback type 1, id 0
entered"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} <core>
[core\/crypto\/md5utils.c:67]: MD5StringArray(): MD5 calculated:
3071029feb05962b26b53a9664a14210"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} siputils [checks.c:123]:
has_totag(): totag found"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} rr [loose.c:1095]:
check_route_param(): route params checking against
[;r2=on;lr=on;ftag=Eb~TbdfTA;did=cab.01e2;nat=yes] (orig:
[r2=on;lr=on;ftag=Eb~TbdfTA;did=cab.01e2;nat=yes])"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} rr [loose.c:1101]:
check_route_param(): params are
<;r2=on;lr=on;ftag=Eb~TbdfTA;did=cab.01e2;nat=yes>"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} siputils [checks.c:123]:
has_totag(): totag found"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} <core>
[core\/msg_translator.c:161]: check_via_address(): (198.1.54.228,
198.1.54.228, 0)"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} <core>
[core\/tcp_main.c:2060]: tcp_send(): no open tcp connection found, opening
new one"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} <core>
[core\/ip_addr.c:229]: print_ip(): tcpconn_new: new tcp connection:
35.191.0.66"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} <core>
[core\/tcp_main.c:1242]: tcpconn_new(): on port 60271, type 3"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} <core>
[core\/tcp_main.c:1561]: tcpconn_add(): hashes: 1446:2350:0, 5"}
"message":" DEBUG: {1 11727734 BYE 5-LX4GdI9X} tls [tls_server.c:199]:
tls_complete_init(): completing tls connection initialization"}
...
So time to seek help from the community, any suggestions/ideas/comments?
Sorry if all this sounds confusing, I've tried my best to put in text the
whole scenario in and "understandable" way...
Is this even doable?
Thanks,
Joel.
Hello,
How can we enforce REGISTER with AKAv1?
Here our setup
1. kamailio version 4.3.4 for IMS
2. Boghe IMS client v1.0.58.550
3. scscf.cfg is configure with:
#!define REG_AUTH_DEFAULT_ALG "AKAv1-MD5"
4. Set Authentication Schemes in Private User Identity - IMPI for user bob
to:
Digest-AKAv1 (3GPP)
results:
First REGISTER fails with 401 Unauthorized
Second REGISTER 200 OK, but the REGISTER is MD5 and not AKAv1
Attached is tcpdump.
By the way: in which DB should we find Authentication Schemes? can't find
it in hss_db, kamailio and not in scscf.
Thank you,
Moshe.
Hello
I have installed and configured both Kamailio and RTP Proxy and calls are
going. But i m unable to force media to go thru RTP Proxy.
How can i enforce media to go thru RTP Proxy ?
Thanks
--
Regards
===================
Sujit Roy
Hi,
I have been working on kamailio with following scenario:
1. Webrtc SIP Users register to Kamailio
2. Users initiate outgoing calls to some other numbers
3. Kamailio dispatches outgoing calls to Asterisk
4. Asterisk answers the call and then send a text message to the caller
using SendText, which was working fine a few days back but all of sudden it
has stopped working
5. At Asterisk end it is showing that message was delivered successfully
but when I check SIP user logs, there is no message event.
Please review my config file at following URL:
https://gist.github.com/adeshpandey/2c338db7f5d992267f7415de0325e0b4
Developers, I also want to know if there is any way to log *text message*
in kamailio server.
Hi
I have two network interfaces on my system in which one interface is
connected to my office WAN/LAN and other is connected to SIP private
network connected to PSTN.
Now, I want to access sip server using the internal IP of our office LAN as
proxy.
*192.168.6.2 (Office LAN IP as proxy) -> 10.50.185.2 (SIP)*
So on machine 192.168.6.2, I setup kamailio as SIP proxy server so that our
office LAN machine can connect to SIP server directly via SIP proxy.
I used config defined in -
*https://github.com/kamailio/kamailio/blob/master/misc/examples/mixed/kamailio-minimal-proxy.cfg*
<https://github.com/kamailio/kamailio/blob/master/misc/examples/mixed/kamail…>
and I changed the local domain alias with SIP IP -* 10.50.185.2*.
When I try to connect to SIP via proxy using *linphone* (UDP) I got below
errors in* /var/log/syslog* and shows *connection in progress* every time.
Nov 23 15:15:49 ubantudesk /usr/sbin/kamailio[25784]: WARNING: {1 20
REGISTER ek82LguQ6z} sanity [sanity.c:585]: check_cl(): content length
header missing in request
Nov 23 15:15:53 ubantudesk /usr/sbin/kamailio[25785]: WARNING: {1 20
REGISTER ek82LguQ6z} sanity [sanity.c:585]: check_cl(): content length
header missing in request
Nov 23 15:15:57 ubantudesk /usr/sbin/kamailio[25784]: WARNING: {1 20
REGISTER ek82LguQ6z} sanity [sanity.c:585]: check_cl(): content length
header missing in request
Nov 23 15:16:01 ubantudesk /usr/sbin/kamailio[25785]: WARNING: {1 20
REGISTER ek82LguQ6z} sanity [sanity.c:585]: check_cl(): content length
header missing in request
Nov 23 15:16:05 ubantudesk /usr/sbin/kamailio[25784]: WARNING: {1 20
REGISTER ek82LguQ6z} sanity [sanity.c:585]: check_cl(): content length
header missing in request
Can you help me what I should do?
--
*Thanks & Regards,*
*Ashwini Kumar | Technology |*
www.industrybuying.com |
Ghitorni, Delhi - 110030 | India |
È*+91-8802137782* | * ashwinikumar(a)industrybuying.com |
Hello,
I'm trying out redis as db backend, and right now I only have dispatcher
records there... Every so often, I do a ds_reload() from within Kam config
script, and I see in logs:
Nov 22 20:36:35 test COPS[25531]: WARNING: db_redis [redis_dbase.c:1098]:
db_redis_perform_query(): performing full table scan on table 'dispatcher'
while performing query
After enabling debug logs:
Nov 22 21:15:35 test COPS[26661]: DEBUG: db_redis [redis_dbase.c:1761]:
db_redis_query(): querying prefix (table) 'dispatcher'
Nov 22 21:15:35 test COPS[26661]: DEBUG: db_redis [redis_dbase.c:1811]:
db_redis_query(): no columns given to build query keys, falling back to
full table scan
Nov 22 21:15:35 test COPS[26661]: DEBUG: <core> [db_res.c:119]:
db_new_result(): allocate 56 bytes for result set at 0x7f0be4273898
Nov 22 21:15:35 test COPS[26661]: DEBUG: <core> [db_res.c:156]:
db_allocate_columns(): allocate 40 bytes for result names at 0x7f0be4273938
Nov 22 21:15:35 test COPS[26661]: DEBUG: <core> [db_res.c:167]:
db_allocate_columns(): allocate 20 bytes for result types at 0x7f0be42739c8
Nov 22 21:15:35 test COPS[26661]: WARNING: db_redis [redis_dbase.c:1098]:
db_redis_perform_query(): performing full table scan on table 'dispatcher'
while performing query
Given the msg... "no columns given to build query keys, falling back to
full table scan", I assume I'm missing a keys modparam.. but I don't know
how to build it, and the docs (to me) seem confusing?
https://kamailio.org/docs/modules/devel/modules/db_redis.html#db_redis.p.ke…
Can anyone help me understand how to build the keys modparam for dispatcher
table? Or if the reason for this is different, what do I need to do to
avoid the full table scan and the warning in the log?
Thanks,
Joel.