connect(true, NULL, $username, $password)) { exit(1); } $mqtt->debug = true; $topics['bluerhinos/phpMQTT/examples/publishtest'] = array('qos' => 0, 'function' => 'procMsg'); $mqtt->subscribe($topics, 0); while($mqtt->proc()) { } $mqtt->close(); function procMsg($topic, $msg){ echo 'Msg Recieved: ' . date('r') . "\n"; echo "Topic: {$topic}\n\n"; echo "\t$msg\n\n"; }