please help me, why I don’t receive a message after publish, all login, submit details are correct. I send the data, but I do not receive the return message..
try {
// Create a new instance of an MQTT client and configure it to use the shared broker host and port.
$client = new MqttClient($host, 1883, $clientID, MqttClient::MQTT_3_1, null);
// Create and configure the connection settings as required.
$connectionSettings = (new ConnectionSettings)
->setUsername($username)
->setPassword($password);
// Connect to the broker with the configured connection settings and with a clean session.
$client->connect($connectionSettings, true);
$handler = function (MqttClient $client, $topic, $message, $messageId, int $qualityOfService, bool $retain) use ($logger) {
//Missing received msg
};
$client->registerPublishEventHandler($handler);
// Publish the message 'Hello world!' on the topic 'foo/bar/baz' using QoS 0.
$client->publish($topic, $msg, MqttClient::QOS_AT_MOST_ONCE);
// Gracefully terminate the connection to the broker.
$client->disconnect();
} catch (MqttClientException $e) {
// MqttClientException is the base exception of all exceptions in the library. Catching it will catch all MQTT related exceptions.
echo "no connected";
}