diff --git a/h2r-bwmsgsv2.php b/h2r-bwmsgsv2.php index d5bc86ccac0ef2fdad7e8c8e3cf84830263137b9..a5407ba05a031f74a117c5b828fa296c62b37cd8 100644 --- a/h2r-bwmsgsv2.php +++ b/h2r-bwmsgsv2.php @@ -24,9 +24,13 @@ $raw_data = file_get_contents('php://input'); include 'settings-h2r.php'; $redis = new Redis(); -$redis->pconnect($redis_host, $redis_port); +$rv = $redis->pconnect($redis_host, $redis_port); -# TODO: check for return value of FALSE and then print raw_data and return !200 +if (!$rv) { + error_log("ERROR 1a in Redis connect at $time - cannot save $raw_data"); + http_response_code(503); # Service Unavailable + exit(0); +} if (!empty($redis_auth)) { # TODO: check return value to confirm login succeeded @@ -37,12 +41,14 @@ if (!empty($redis_auth)) { $time2 = microtime(true); -$redis->lPush('incoming_messages-'.'test1a', # TODO: update queue name +$rv = $redis->lPush('incoming_messages-'.'test1a', # TODO: update queue name '"ts_020-first_db_hit":'.$time2.',"ts_010-first_received":'.$time.',"MSG":'.$raw_data); -# TODO: check for return value of FALSE and then print raw_data and return !200 - -# TODO: test syntax error to ensure non-200 is returned +if (!$rv) { + error_log("ERROR 2a in lPush at $time $time2 - cannot save $raw_data"); + http_response_code(503); # Service Unavailable + exit(0); +} print 'ok';