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