Git Product home page Git Product logo

client-examples's People

Contributors

namoshek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

client-examples's Issues

Establishing a connection to the MQTT broker failed

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();

Setup and configuring

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

Uncaught Error: Class 'PhpMqtt\Client\MqttClient' not found

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.