[solved] Error with logging and adding sleep to blocked gateway

Hi Anton,

I recently downloaded playsms and I think you have done a great job. While trying out the functions, I saw some error with debiting / crediting when I used the blocked gateway.

I tried to view the playsms.log and I noticed that the log “enter smsc” was not stored. This log is found in plugin/gateway/blocked/fn.php

I tried to set the error logstate to 3 and 4 in config.php but this statement still doesnt get logged to playsms.log.

Another issue I had was I wanted to slow the throughput so I added a sleep(10000) but I can see that the sleep call doesn’t work. Is there some function/ config I need to configure?

I am using ubuntu for dev environment.

Thanks in advance.

ok, I’ll check the blocked gateway.

where do you add sleep ? also, have you restart playsmsd ?

anton

I added sleep(10000) to function below.

The _log(“enter SMSC …”); call also doesn’t seem to be logging correctly as I can’t find it in playsms.log.

<?php defined('_SECURE_') or die('Forbidden'); function blocked_hook_sendsms($smsc, $sms_sender, $sms_footer, $sms_to, $sms_msg, $uid = '', $gpid = 0, $smslog_id = 0, $sms_type = 'text', $unicode = 0) { global $plugin_config; _log("enter smsc:" . $smsc . " smslog_id:" . $smslog_id . " uid:" . $uid . " to:" . $sms_to, 3, "blocked_hook_sendsms"); // override plugin gateway configuration by smsc configuration $plugin_config = gateway_apply_smsc_config($smsc, $plugin_config); $p_status = 2; dlr($smslog_id, $uid, $p_status); sleep(10000); return TRUE; }

I used the send from file to test with 5000 numbers to blocked gateway and discovered that sleep() doesn’t seem to work and the _log missing in playsms.log.

check that you have enabled logstate 3, because the log is printed out on logstate 3

  • edit config.php on playSMS web root folder
  • look for logstate, and edit to 3, the default is 2
  • then dont forget to restart playsmsd, run: playsmsd restart on linux console

theres also possibility that the message didn’t routed to blocked, have you correctly configured route outgoing SMS ?

I usually set in Settings->Main configuration the default route to “blocked”, then route each prefix (like your country code or zero) in Settings->Route outgoing SMS.

anton

anton

Outgoing sms is routed correctly. Under sent messages these are reflected as failed and credits are refunded. I also checked MySQL and the SMSC is correctly pointed to the blocked gateway.

The strange thing is the log function doesn’t seem to print (I tried log state 3 and also amending fn.php to set the level to 2). The sleep function doesn’t work too.

Do I need to explicitly declare/ include the logger function again?

Hi Anton,

I tested with a testsleep.php file that is saved at playsms folder (same folder as index.php) and the sleep () function works perfectly. but when I add sleep () to the fn.php for dev gateway the sleep () function doesn’t work.

Does the daemon or some other script affect the sleep?

<php?
echo (“testing sleep function”);

for ($x=0; $x<10; $x++)
{sleep(5);
echo (“loop:” . $x . date (“h:i:sa”));

}

I have tested this, I got no issue adding sleep(10) in plugin/feature/gateway/blocked/fn.php

here is the log when I added it and SMS routed to blocked:

- - 2015-07-15 04:25:18 PID55a57e3de49c9 - L2 sendsms_process # start
- - 2015-07-15 04:25:18 PID55a57e3de49c9 - L3 simplerate_hook_rate_getbyprefix # rate not found to:9988776655 default_rate:0
- - 2015-07-15 04:25:18 PID55a57e3de49c9 - L3 simplerate_hook_rate_getcharges # uid:1 u:admin len:26 unicode:0 to:9988776655 enable_credit_unicode:1 count:1 rate: charge:0
- - 2015-07-15 04:25:18 PID55a57e3de49c9 - L2 simplerate__cansend # allowed user uid:1 sms_to:9988776655 credit:0.000 count:1 rate: charge:0 balance:0
- - 2015-07-15 04:25:18 PID55a57e3de49c9 - L2 sendsms # saving smslog_id:162 u:1 g:0 gw:blocked smsc:blocked s:TESTSENDER d:9988776655 type:text unicode:0 status:0
- - 2015-07-15 04:25:18 PID55a57e3de49c9 - L2 sendsms_process # saved smslog_id:162 id:162
- - 2015-07-15 04:25:18 PID55a57e3de49c9 - L3 sendsms # final smslog_id:162 gw:blocked smsc:blocked message:Hi u there, good morning!! len:26
- - 2015-07-15 04:25:18 PID55a57e3de49c9 - L3 blocked_hook_sendsms # enter smsc:blocked smslog_id:162 uid:1 to:9988776655
- - 2015-07-15 04:25:18 PID55a57e3de49c9 - L3 blocked_hook_sendsms # before sleep 10
- - 2015-07-15 04:25:28 PID55a57e3de49c9 - L3 blocked_hook_sendsms # after sleep 10
- - 2015-07-15 04:25:28 PID55a57e3de49c9 - L3 dlr # isdlrd:1 smslog_id:162 p_status:2 uid:1

look closely, the time, it was delayed for 10 seconds:

- - 2015-07-15 04:25:18 PID55a57e3de49c9 - L3 blocked_hook_sendsms # enter smsc:blocked smslog_id:162 uid:1 to:9988776655
- - 2015-07-15 04:25:18 PID55a57e3de49c9 - L3 blocked_hook_sendsms # before sleep 10
- - 2015-07-15 04:25:28 PID55a57e3de49c9 - L3 blocked_hook_sendsms # after sleep 10

here is the changes I made to fn.php:

anton

Hi Anton,

Thanks for your help. Somehow it didn’t work for me. Will try again with a fresh installation.

Hi Anton,

Issue solved. Installed ubuntu server instead and the playsms code was running perfectly.