When i execute the code from the command line the message is sent correctly, but when i call the same code from a browser i get "http error 500".
PHP 5.6.27-0+deb8u1 (cli) (built: Oct 15 2016 15:53:28)
mosquitto version 1.4.10 (build date Thu, 25 Aug 2016 10:12:09 +0100)
php.ini includes: extension=mosquitto.so
php -m shows mosquitto is loaded
nginx/1.6.2
nginx error log ==> FastCGI sent in stderr: "PHP Fatal error: Class 'Mosquitto\Client' not found in /var/www/html/mqttTest.php on line 7" while reading response header from upstream, client: {ipaddress-here}, s$
When i execute the code from the command line the message is sent correctly, but when i call the same code from a browser i get "http error 500".
PHP Code:
<?php include_once "mqtt-credentials.php";
$topic = "test";
try { $client = new Mosquitto\Client("0", true); $client->setCredentials($username, $password); $client->connect($server, $port, 60); $message = "test msg"; $client->publish($topic, $message, 1); $client->disconnect(); } catch (Exception $e) { echo $e; } ?>