Skip to content

MSILO module

This modules provides offline message storage for the Open SIP Server. It stores received messages for an offline user and sends them when the user becomes online.

For each message, the modules stores “Request-URI” (“R-URI”) only if it is a complete address of record (“username@hostname”), URI from “To” header, URI from “From” header, incoming time, expiration time, content type and body of the message. If “R-URI” is not an address of record (it might be the contact address for current SIP session) the URI from “To” header will be used as R-URI.

When the expiration time passed, the message is discarded from database. Expiration time is computed based on incoming time and one of the module’s parameters.

Every time when a user registers with OpenSIPS, the module is looking in database for offline messages intended for that user. All of them will be sent to contact address provided in REGISTER request.

It may happen the SIP user to be registered but his SIP User Agent to have no support for MESSAGE request. In this case it should be used the “failure_route” to store the undelivered requests.

Another functionality provided by the modules is to send messages at a certain time — the reminder functionality. Using config logic, a received message can be stored and delivered at a time specified while storing with the ‘snd_time_avp’.

The following modules must be loaded before this module:

  • database module - mysql, dbtext or other module that implements the “db” interface and provides support for storing/receiving data to/from a database system.
  • TM—transaction module—is used to send SIP requests.

The following libraries or applications must be installed before running OpenSIPS with this module:

  • none.

Database URL.

Default value is “mysql://opensips:opensipsrw@localhost/opensips”.

Set the 'db_url' parameter
...
modparam("msilo", "db_url", "mysql://user:passwd@host.com/dbname")
...

The name of table where to store the messages.

Default value is “silo”.

Set the 'db_table' parameter
...
modparam("msilo", "db_table", "silo")
...

The SIP address used to inform users that destination of their message is not online and the message will be delivered next time when that user goes online. If the parameter is not set, the module will not send any notification. It can contain pseudo-variables.

Default value is “NULL”.

Set the 'from_address' parameter
...
modparam("msilo", "from_address", "sip:registrar@example.org")
modparam("msilo", "from_address", "sip:$rU@example.org")
...

The value of the Contact header (including header name and ending \r\n) to be added in notification messages. It can contain pseudo-variables.

Default value is “NULL”.

Set the 'contact_hdr' parameter
...
modparam("msilo", "contact_hdr", "Contact: <sip:null@example.com>\r\n")
...

The body of the notification message. It can contain pseudo-variables.

Default value is “NULL”.

Set the 'offline_message' parameter
...
modparam("msilo", "offline_message", "*** User $rU is offline!")
modparam("msilo", "offline_message", "<em>I am offline!</em>")
...

The value of the Content-Type header (including header name and ending \r\n) to be added in notification messages. It must reflect what the ‘offline_message’ contains. It can contain pseudo-variables.

Default value is “NULL”.

Set the 'content_type_hdr' parameter
...
modparam("msilo", "content_type_hdr", "Content-Type: text/plain\r\n")
modparam("msilo", "content_type_hdr", "Content-Type: text/html\r\n")
...

The SIP address used to send reminder messages. If this value is not set, the reminder feature is disabled.

Default value is “NULL”.

Set the 'reminder' parameter
...
modparam("msilo", "reminder", "sip:registrar@example.org")
...

The SIP address used as next hop when sending the message. Very useful when using OpenSIPS with a domain name not in DNS, or when using a separate OpenSIPS instance for msilo processing. If not set, the message will be sent to the address in destination URI.

Default value is “NULL”.

Set the 'outbound_proxy' parameter
...
modparam("msilo", "outbound_proxy", "sip:opensips.org;transport=tcp")
...

Expire time of stored messages - seconds. When this time passed, the message is silently discarded from database.

Default value is “259200 (72 hours = 3 days)“.

Set the 'expire_time' parameter
...
modparam("msilo", "expire_time", 36000)
...

Timer interval to check if dumped messages are sent OK - seconds. The module keeps each request send by itself for a new online user and if the reply is 2xx then the message is deleted from database.

Default value is “30”.

Set the 'check_time' parameter
...
modparam("msilo", "check_time", 10)
...

Timer interval in seconds to check if there are reminder messages. The module takes all reminder messages that must be sent at that moment or before that moment.

If the value is 0, the reminder feature is disabled.

Default value is “0”.

Set the 'send_time' parameter
...
modparam("msilo", "send_time", 60)
...

Number of “check_time” cycles when to check if there are expired messages in database.

Default value is “5”.

Set the 'clean_period' parameter
...
modparam("msilo", "clean_period", 3)
...

Turns on/off the usage of the Contact address to send notification back to sender whose message is stored by MSILO.

Default value is “1 (0 = off, 1 = on)“.

Set the 'use_contact' parameter
...
modparam("msilo", "use_contact", 0)
...

The name of the column in silo table, storing message id.

Default value is “mid”.

Set the 'sc_mid' parameter
...
modparam("msilo", "sc_mid", "other_mid")
...

The name of the column in silo table, storing the source address.

Default value is “src_addr”.

Set the 'sc_from' parameter
...
modparam("msilo", "sc_from", "source_address")
...

The name of the column in silo table, storing the destination address.

Default value is “dst_addr”.

Set the 'sc_to' parameter
...
modparam("msilo", "sc_to", "destination_address")
...

The name of the column in silo table, storing the user name.

Default value is “username”.

Set the 'sc_uri_user' parameter
...
modparam("msilo", "sc_uri_user", "user")
...

The name of the column in silo table, storing the domain.

Default value is “domain”.

Set the 'sc_uri_host' parameter
...
modparam("msilo", "sc_uri_host", "domain")
...

The name of the column storing the message body in silo table.

Default value is “body”.

Set the 'sc_body' parameter
...
modparam("msilo", "sc_body", "message_body")
...

The name of the column in silo table, storing content type.

Default value is “ctype”.

Set the 'sc_ctype' parameter
...
modparam("msilo", "sc_ctype", "content_type")
...

The name of the column in silo table, storing the expire time of the message.

Default value is “exp_time”.

Set the 'sc_exp_time' parameter
...
modparam("msilo", "sc_exp_time", "expire_time")
...

The name of the column in silo table, storing the incoming time of the message.

Default value is “inc_time”.

Set the 'sc_inc_time' parameter
...
modparam("msilo", "sc_inc_time", "incoming_time")
...

The name of the column in silo table, storing the send time for the reminder.

Default value is “snd_time”.

Set the 'sc_snd_time' parameter
...
modparam("msilo", "sc_snd_time", "send_reminder_time")
...

The name of an AVP which may contain the time when to sent the received message as reminder.The AVP is used ony by m_store().

If the parameter is not set, the module does not look for this AVP. If the value is set to a valid AVP name, then the module expects in the AVP to be a time value in format YYYYMMDDHHMMSS (e.g., 20060101201500).

Default value is “null”.

Set the 'snd_time_avp' parameter
...
modparam("msilo", "snd_time_avp", "$avp(snd_time)")
...

Wheter to add as prefix the date when the message was stored.

Default value is “1” (1==on/0==off).

Set the 'add_date' parameter
...
modparam("msilo", "add_date", 0)
...

Maximum number of stored message for an AoR. Value 0 equals to no limit.

Default value is 0.

Set the 'max_messages' parameter
...
modparam("msilo", "max_messages", 0)
...

The method stores certain parts of the current SIP request (it should be called when the request type is MESSAGE and the destination user is offline or his UA does not support MESSAGE requests). If the user is registered with a UA which does not support MESSAGE requests you should not use mode=“0” if you have changed the request uri with the contact address of user’s UA.

Meaning of the parameters is as follows:

  • owner (string, optional) - a SIP URI in whose inbox the message will be stored. If “owner” is missing, the SIP address is taken from R-URI.

This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.

m_store usage
...
m_store();
m_store($tu);
...

The method sends stored messages for the SIP user that is going to register to his actual contact address. The method should be called when a REGISTER request is received and the “Expire” header has a value greater than zero.

Meaning of the parameters is as follows:

  • owner (string, optional) - a SIP URI whose inbox will be dumped. If “owner” is missing, the SIP address is taken from To URI.
  • maxmsg (int, optional) - is a maximum number of messages to be dumped.

This function can be used from REQUEST_ROUTE, STARTUP_ROUTE, TIMER_ROUTE, EVENT_ROUTE

m_dump usage
...
m_dump();
m_dump($fu);
m_dump($fu, 10);
...

The number of messages stored by msilo.

The number of dumped messages.

The number of failed dumped messages.

The number of dumped reminder messages.

The number of failed reminder messages.

OpenSIPS Config Script - Msilo (Message SILO) Usage

Section titled “OpenSIPS Config Script - Msilo (Message SILO) Usage”
#
# OpenSIPS Message SILO configuration script
# by OpenSIPS Solutions <team@opensips-solutions.com>
#
# This is a basic msilo configuration. Ready-to-use M4 templates are
# available under examples/templates/.
#
# Please refer to the OpenSIPS Manuals at:
# https://opensips.org/Documentation/Manuals
# for an explanation of available statements, functions and parameters.
#
####### Global Parameters #########
/* uncomment the following lines to enable debugging */
#debug_mode=yes
log_level=3
xlog_level=3
stderror_enabled=no
syslog_enabled=yes
syslog_facility=LOG_LOCAL0
udp_workers=4
/* uncomment the next line to enable the auto temporary blacklisting of
not available destinations (default disabled) */
#disable_dns_blacklist=no
/* uncomment the next line to enable IPv6 lookup after IPv4 dns
lookup failures (default disabled) */
#dns_try_ipv6=yes
socket=udp:127.0.0.1:5060 # CUSTOMIZE ME
####### Modules Section ########
#set module path
mpath="/usr/local/lib/opensips/modules/"
#### SIGNALING module
loadmodule "signaling.so"
#### StateLess module
loadmodule "sl.so"
#### Transaction Module
loadmodule "tm.so"
modparam("tm", "fr_timeout", 5)
modparam("tm", "fr_inv_timeout", 30)
modparam("tm", "restart_fr_on_each_reply", 0)
modparam("tm", "onreply_avp_mode", 1)
#### Record Route Module
loadmodule "rr.so"
/* do not append from tag to the RR (no need for this script) */
modparam("rr", "append_fromtag", 0)
#### MAX ForWarD module
loadmodule "maxfwd.so"
#### SIP MSG OPerationS module
loadmodule "sipmsgops.so"
#### FIFO Management Interface
loadmodule "mi_fifo.so"
modparam("mi_fifo", "fifo_name", "/run/opensips/opensips_fifo")
modparam("mi_fifo", "fifo_mode", 0666)
#### USeR LOCation module
loadmodule "usrloc.so"
modparam("usrloc", "nat_bflag", "NAT")
modparam("usrloc", "working_mode_preset", "single-instance-no-db")
#### REGISTRAR module
loadmodule "registrar.so"
modparam("registrar", "tcp_persistent_flag", "TCP_PERSISTENT")
/* uncomment the next line not to allow more than 10 contacts per AOR */
#modparam("registrar", "max_contacts", 10)
#### ACCounting module
loadmodule "acc.so"
/* what special events should be accounted ? */
modparam("acc", "early_media", 0)
modparam("acc", "report_cancels", 0)
/* by default we do not adjust the direct of the sequential requests.
if you enable this parameter, be sure to enable "append_fromtag"
in "rr" module */
modparam("acc", "detect_direction", 0)
#### DB MYSQL module
loadmodule "db_mysql.so"
#### Message SILO module
loadmodule "msilo.so"
modparam("msilo","db_url","mysql://opensips:opensipsrw@localhost/opensips")
# notifications to senders
modparam("msilo","offline_message","User $rU@$rd is offline, your message was stored for later delivery")
modparam("msilo","contact_hdr","Contact: message_handler@127.0.0.1:5060;msilo=yes\r\n")
modparam("msilo","content_type_hdr", "Content-Type: text/plain\r\n")
modparam("msilo","from_address","sip:message_handler@127.0.0.1")
# no reminders
modparam("msilo", "send_time", 0)
loadmodule "proto_udp.so"
####### Routing Logic ########
# main request routing logic
route{
if (!mf_process_maxfwd_header(10)) {
send_reply(483,"Too Many Hops");
exit;
}
if (has_totag()) {
# handle hop-by-hop ACK (no routing required)
if ( is_method("ACK") && t_check_trans() ) {
t_relay();
exit;
}
# sequential request within a dialog should
# take the path determined by record-routing
if ( !loose_route() ) {
# we do record-routing for all our traffic, so we should not
# receive any sequential requests without Route hdr.
send_reply(404,"Not here");
exit;
}
if (is_method("BYE")) {
# do accounting even if the transaction fails
do_accounting("log","failed");
}
# route it out to whatever destination was set by loose_route()
# in $du (destination URI).
route(relay);
exit;
}
# CANCEL processing
if (is_method("CANCEL")) {
if (t_check_trans())
t_relay();
exit;
}
# absorb retransmissions, but do not create transaction
t_check_trans();
if ( !(is_method("REGISTER") ) ) {
if (is_myself("$fd")) {
} else {
# if caller is not local, then called number must be local
if (!is_myself("$rd")) {
send_reply(403,"Relay Forbidden");
exit;
}
}
}
# preloaded route checking
if (loose_route()) {
xlog("L_ERR",
"Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
if (!is_method("ACK"))
send_reply(403,"Preload Route denied");
exit;
}
# record routing
if (!is_method("REGISTER|MESSAGE"))
record_route();
# account only INVITEs
if (is_method("INVITE")) {
do_accounting("log");
}
if (!is_myself("$rd")) {
append_hf("P-hint: outbound\r\n");
route(relay);
}
# requests for my domain
if (is_method("PUBLISH|SUBSCRIBE")) {
send_reply(503, "Service Unavailable");
exit;
}
if (is_method("REGISTER")) {
# store the registration and generate a SIP reply
if (!save("location"))
xlog("failed to register AoR $tu\n");
else {
xlog("successful REGISTER -> dumping MSILO for $tu\n");
# MSILO - dumping user's offline messages
if (m_dump($tu)) {
xlog("MSILO: offline messages dumped - if they were\n");
} else {
xlog("MSILO: no offline messages dumped\n");
}
}
exit;
}
if ($rU==NULL) {
# request with no Username in RURI
send_reply(484,"Address Incomplete");
exit;
}
# we may need (for msilo) the calle AOR later ; store it as RURI will
# be changed by lookup(location) with the registered contact
$avp(callee_uri) = $ru;
# do lookup with method filtering
if (!lookup("location","method-filtering")) {
# store it if a MESSAGE, for later delivery
if (is_method("MESSAGE")) {
xlog("MESSAGE received for $ru-> storing using MSILO\n");
t_newtran();
# MSILO - storing as offline message
if (m_store("$ru")) {
xlog("MSILO: offline message stored\n");
t_reply(202, "Accepted");
}else{
xlog("MSILO: offline message NOT stored\n");
t_reply(503, "Service Unavailable");
}
exit;
}
t_reply(486, "Unavailable");
exit;
}
# when sending a MESSAGE to the user, use a different failure route
# in order to see if the MESSAGE was accepted or not
# TAKE CARE not to conflict with other failure_route setting
if (is_method("MESSAGE")) {
t_on_failure("msg_failed");
}
# when routing via usrloc, log the missed calls also
do_accounting("log","missed");
route(relay);
}
route[relay] {
# for INVITEs enable some additional helper routes
if (is_method("INVITE")) {
t_on_branch("per_branch_ops");
t_on_reply("handle_nat");
t_on_failure("missed_call");
}
if (!t_relay()) {
send_reply(500,"Internal Error");
}
exit;
}
branch_route[per_branch_ops] {
xlog("new branch at $ru\n");
}
onreply_route[handle_nat] {
xlog("incoming reply\n");
}
failure_route[missed_call] {
if (t_was_cancelled()) {
exit;
}
# uncomment the following lines if you want to block client
# redirect based on 3xx replies.
##if (t_check_status("3[0-9][0-9]")) {
##t_reply(404,"Not found");
## exit;
##}
}
failure_route[msg_failed] {
# this is armed only for MESSAGEs to users
xlog("MSILO: the callee UA doesn't support MESSAGEs, replied with $T_reply_code \n");
if (m_store( $avp(callee_uri) )){
xlog("MSILO: offline message stored for $avp(callee_uri)\n");
t_reply(202, "Accepted");
}else{
xlog("MSILO: offline message NOT stored for $avp(callee_uri)\n");
t_reply(503, "Service Unavailable");
};
}
local_route {
# here we can see the MESSAGE requests generated by MSILO
# NOTE : these MESSAGEs go directly from OpenSIPS to the user
if (is_method("MESSAGE")) {
xlog("MSILO: stored message being sent to callee $tu\n");
}
}

Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)

#NameDevScoreCommitsLines++Lines—
1.Daniel-Constantin Mierla (@miconda)1336644521699
2.Bogdan-Andrei Iancu (@bogdan-iancu)5741698572
3.Liviu Chircu (@liviuchircu)2014185201
4.Jan Janak (@janakj)2011282324
5.Andrei Pelinescu-Onciul1810117384
6.Razvan Crainea (@razvancrainea)14123631
7.Stefan Darius (@dariusstefan)144888104
8.Henning Westerholt (@henningw)116127123
9.Jiri Kuthan (@jiriatipteldotorg)9618841
10.Vlad Patrascu (@rvlad-patrascu)9570124

All remaining contributors: Juha Heinanen (@juha-h), Andrea Giordana, Vlad Paiu (@vladpaiu), Ancuta Onofrei, Elena-Ramona Modroiu, Maksym Sobolyev (@sobomax), Aron Rosenberg, Ovidiu Sas (@ovidiusas), John Riordan, Alexandra Titoc, Konstantin Bokarius, Zero King (@l2dy), Peter Lemenkov (@lemenkov), Julián Moreno Patiño, UnixDev, Sergio Gutierrez, Edson Gellert Schubert, Stanislaw Pitucha.

(1) DevScore = author_commits + author_lines_added / (project_lines_added / project_commits) + author_lines_deleted / (project_lines_deleted / project_commits)

(2) including any documentation-related commits, excluding merge commits

(3) ignoring whitespace edits, renamed files and auto-generated files

#NameCommit Activity
1.Bogdan-Andrei Iancu (@bogdan-iancu)Sep 2002 - Jul 2026
2.Stefan Darius (@dariusstefan)Jun 2026 - Jul 2026
3.Razvan Crainea (@razvancrainea)Jun 2011 - Jun 2026
4.Alexandra TitocSep 2024 - Sep 2024
5.Liviu Chircu (@liviuchircu)Mar 2014 - May 2024
6.Maksym Sobolyev (@sobomax)Feb 2023 - Feb 2023
7.Ovidiu Sas (@ovidiusas)Apr 2022 - Apr 2022
8.Zero King (@l2dy)Mar 2020 - Mar 2020
9.Vlad Patrascu (@rvlad-patrascu)May 2017 - Apr 2019
10.Peter Lemenkov (@lemenkov)Jun 2018 - Jun 2018

All remaining contributors: Julián Moreno Patiño, Vlad Paiu (@vladpaiu), Stanislaw Pitucha, John Riordan, UnixDev, Sergio Gutierrez, Henning Westerholt (@henningw), Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert, Ancuta Onofrei, Aron Rosenberg, Elena-Ramona Modroiu, Juha Heinanen (@juha-h), Andrea Giordana, Andrei Pelinescu-Onciul, Jan Janak (@janakj), Jiri Kuthan (@jiriatipteldotorg).

(1) including any documentation-related commits, excluding merge commits

Last edited by: Razvan Crainea (@razvancrainea), Liviu Chircu (@liviuchircu), Bogdan-Andrei Iancu (@bogdan-iancu), Vlad Patrascu (@rvlad-patrascu), Peter Lemenkov (@lemenkov), Vlad Paiu (@vladpaiu), Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert, Elena-Ramona Modroiu, Juha Heinanen (@juha-h), Andrea Giordana, Jan Janak (@janakj).

All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0