Hello,
I'm trying to do a sleep in the request route but seems it's not working
if (src_ip == $sel(cfg_get.kamalio2.gw) ){ xlog("L_NOTICE","Sleep 5 seconds"); usleep("5000"); }
xlog("L_NOTICE","End of sleeping");
Result :
Jul 21 11:38:02 proxy2 /usr/sbin/kamailio[31442]: NOTICE: <script>: Sleep 5 seconds Jul 21 11:38:02 proxy2 /usr/sbin/kamailio[31442]: NOTICE: <script>: End of sleeping
Breuer Nicolas Network Supervisor Sales Executive
BELCENTER sprl/bvba Operations - NCC 7 Boulevard de France, 1420 Braine - L'Alleud
Tel +32 2 403 04 61 Fax +32 2 403 04 63
National Contact Center +32 2 403 04 60
Hi Nicholas,
On Fri, Jul 21, 2017 at 09:39:35AM +0000, Nicolas Breuer wrote:
Hello,
I'm trying to do a sleep in the request route but seems it's not working
if (src_ip == $sel(cfg_get.kamalio2.gw) ){ xlog("L_NOTICE","Sleep 5 seconds"); usleep("5000"); } xlog("L_NOTICE","End of sleeping");
Result :
Jul 21 11:38:02 proxy2 /usr/sbin/kamailio[31442]: NOTICE: <script>: Sleep 5 seconds Jul 21 11:38:02 proxy2 /usr/sbin/kamailio[31442]: NOTICE: <script>: End of sleeping
usleep() takes an argument in microseconds (millionths of a second), so you should try a value of 5000000.
But aside from that, embedding sleep commands in request routes is a very bad idea, since it ties up that worker thread during the time it sleeps and prevents it from processing other SIP messages. :-)
-- Alex