php-mqtt / client-examples Goto Github PK
View Code? Open in Web Editor NEWThese are examples showcasing how to use php-mqtt/client.
License: MIT License
These are examples showcasing how to use php-mqtt/client.
License: MIT License
Hello,
I'm trying to subscribe to a mosquitto broker using the given examples but it cant connect, it's either a 500 error or a timeout. Note publishing works without issues. I have used https://github.com/php-mqtt/client-examples/blob/master/02_subscribing/03_subscribe_with_qos_2.php but failed so i was wondering if this a case of outdated code. Any help would be great. Thanks !
I am using aws iot mqtt broker to connect, but getting this error:
[4] Establishing a connection to the MQTT broker failed: The broker did not acknowledge the connection attempt within the configured connection timeout period.
<?php
use PhpMqtt\Client\MqttClient;
use PhpMqtt\Client\ConnectionSettings;
$client = new MqttClient("aws-iot-endpoint", "8883", 'aws-iot-client-id', MqttClient::MQTT_3_1_1);
// Create and configure the connection settings as required.
$connectionSettings = (new ConnectionSettings)
->setUseTls(true)
->setTlsSelfSignedAllowed(true)
->setTlsClientCertificateFile("aws-device-certificate")
->setTlsClientCertificateKeyFile("aws-private-key");
// Connect to the broker with the configured connection settings and with a clean session.
$client->connect($connectionSettings, true);
// Publish the message 'Hello world!' on the topic 'foo/bar/baz' using QoS 0.
$client->publish('foo/bar/baz', 'Hello world!', MqttClient::QOS_AT_MOST_ONCE);
// Gracefully terminate the connection to the broker.
$client->disconnect();
Hi,
Sorry, my background is C++ and I am trying to leave subscription loop if there's no data within 5 seconds.
I have look at this code but no idea how to set loop timeout.
Hi
I am attempting to integrate this with my website. but I keep getting errors on the require . I can see the files listed in c:\users\Administrator\Vendor
So I tried ..
require 'C:/users/Administrator/vendor/autoload.php';
require DIR . '/SimpleLogger.php';
use PhpMqtt\Client\src\Exceptions\ConnectingToBrokerFailedException;
use PhpMqtt\Client\src\Exceptions\DataTransferException;
use PhpMqtt\Client\src\Exceptions\UnexpectedAcknowledgementException;
I also attempted to copy the mentioned files directly to my website folders also get errors..
Is there a tutorial of how to install and configure???
Regards
Meir
I installed php-mqtt
using composer
, but I could not load the class.
require 'vendor/autoload.php';
use \PhpMqtt\Client\MqttClient;
$server = 'localhost';
$port = 1883;
$mqtt = new \PhpMqtt\Client\MqttClient($server, $port);
It always throws this error: PHP Fatal error: Uncaught Error: Class 'PhpMqtt\Client\MqttClient' not found
.
Is there anything else needed to make it work.
Note that I use CentOS 8 server.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.