micropython-umqtt.simple2


Namemicropython-umqtt.simple2 JSON
Version 2.2.0 PyPI version JSON
download
home_pagehttps://github.com/fizista/micropython-umqtt.simple2
SummaryMQTT client for MicroPython.
upload_time2022-12-23 15:30:03
maintainerNone
docs_urlNone
authorWojciech Banaś
requires_pythonNone
licenseMIT
keywords mqtt micropython
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. role:: bash(code)
   :language: bash

.. role:: python(code)
   :language: python

umqtt.simple2
=============

umqtt.simple2_ is a MQTT client for MicroPython. (Note that it uses some
MicroPython shortcuts and doesn't work with CPython).

Support MQTT Version 3.1.1 only.

It certainly works with micropython ports: esp8266 and esp32. It should also
work with other ports, but the library was not tested under other ports.

========  ===========  ========  ===========
          Micropython
Port      Version      Normal    SSL
========  ===========  ========  ===========
esp8266   1.9.1        OK        Test fails
esp32     1.9.1        OK        OK
========  ===========  ========  ===========

MQTT client with more features
------------------------------

There's a separate umqtt.robust2_  module which builds
on umqtt.simple2_ adds the ability to reconnect.
It is able to send unsent messages itself. And many more...

Differences between umqtt.simple and umqtt.simple2
--------------------------------------------------
* When sending messages from QoS=1, there is no problem with "suspending"
  the script while waiting for confirmation of message receipt by the server.
* When subscribing to a channel, there is no problem with "suspending"
  the script while waiting for confirmation of the subscription by the server.
* Information about receiving or failing to receive a message from QoS=1 or subscription
  can only be received by registering a callback using the :python:`set_callback_status()` method.
* Currently, the module informs about errors in more detailed way. See the umqtt/errno.py file.
* The application should also not hang up when using :python:`check_msg()`
* The code compiled for MPY files, is about 30% larger than the original one.
  So this library has gained more functionality (maybe reliability),
  but this was done at the expense of the amount of code.

Problems and solutions
----------------------
* ImportError: no module named 'umqtt.simple2'

  Versions of micropython from http://micropython.org/download/ since version 1.12 include
  the umqtt library, which conflicts with the current library.
  To avoid conflicts, you need to change the order of importing libraries.
  You need to import the '/lib' libraries first and then the system libraries.
  Just add the following lines of code to the boot.py file:

.. code-block:: python

    import sys
    sys.path.reverse()

How and where to install this code?
-----------------------------------
You can install using the upip:

.. code-block:: python

    import upip
    upip.install("micropython-umqtt.simple2")

or

.. code-block:: bash

    micropython -m upip install -p modules micropython-umqtt.simple2


You can also clone this repository, and install it manually:

.. code-block:: bash

    git clone https://github.com/fizista/micropython-umqtt.simple2.git

Manual installation gives you more possibilities:

* You can compile this library into MPY files using the :bash:`compile.sh` script.
* You can remove comments from the code with the command: :bash:`python setup.py minify`
* You can of course copy the code as it is, if you don't mind.

**Please note that the PyPi repositories contain optimized code (no comments).**

Design requirements
-------------------

* Memory efficiency.
* Avoid infamous design anti-patterns like "callback hell".
* Support for both publishing and subscription via a single client
  object (another alternative would be to have separate client classes
  for publishing and subscription).

API design
----------

Based on the requirements above, there are following API traits:

* All data related to MQTT messages is encoded as bytes. This includes
  both message content AND topic names (even though MQTT spec states
  that topic name is UTF-8 encoded). The reason for this is simple:
  what is received over network socket is binary data (bytes) and
  it would require extra step to convert that to a string, spending
  memory on that. Note that this applies only to topic names (because
  they can be both sent and received). Other parameters specified by
  MQTT as UTF-8 encoded (e.g. ClientID) are accepted as strings.
* Subscribed messages are delivered via a callback. This is to avoid
  using a queue for subscribed messages, as otherwise they may be
  received at any time (including when client expects other type
  of server response, so there're 2 choices: either deliver them
  immediately via a callback or queue up until an "expected" response
  arrives). Note that lack of need for a queue is delusive: the
  runtime call stack forms an implicit queue in this case. And unlike
  explicit queue, it's much harder to control. This design was chosen
  because in a common case of processing subscribed messages it's
  the most efficient. However, if in subscription callback, new
  messages of QoS>0 are published, this may lead to deep, or
  infinite recursion (the latter means an application will terminate
  with :python:`RuntimeException`).

API reference
-------------

Taking into account API traits described above, umqtt pretty closely
follows MQTT control operations, and maps them to class methods:

* ``connect(...)`` - Connect to a server. Returns True if this connection
  uses persisten session stored on a server (this will be always False if
  clean_session=True argument is used (default)).
* ``disconnect()`` - Disconnect from a server, release resources.
* ``ping()`` - Ping server (response is processed automatically by wait_msg()).
* ``publish()`` - Publish a message.
* ``subscribe()`` - Subscribe to a topic.
* ``set_callback()`` - Set callback for received subscription messages. call(topic, msg, retained)
* ``set_callback_status()`` - Set callback for received subscription messages. call(pid, status)
* ``set_last_will()`` - Set MQTT "last will" message. Should be called
  *before* connect().
* ``wait_msg()`` - Wait for a server message. A subscription message will be
  delivered to a callback set with set_callback(), any other messages
  will be processed internally.
* ``check_msg()`` - Check if there's pending message from server. If yes,
  process the same way as wait_msg(), if not, return immediately.

``wait_msg()`` and ``check_msg()`` are "main loop iteration" methods, blocking
and non-blocking version. They should be called periodically in a loop,
``wait_msg()`` if you don't have any other foreground tasks to perform
(i.e. your app just reacts to subscribed MQTT messages), ``check_msg()``
if you process other foreground tasks too.

Note that you don't need to call ``wait_msg()``/``check_msg()`` if you only
publish messages with QoS==0, never subscribe to them.

If you are using a subscription and/or sending QoS>0 messages, you must run one of these
commands ( ``wait_msg()`` or ``check_msg()`` ).

**For more detailed information about API please see the source code
(which is quite short and easy to review) and provided examples.**


Supported MQTT features
-----------------------

QoS 0 and 1 are supported for both publish and subscribe. QoS2 isn't
supported to keep code size small. Besides ClientID, only "clean
session" parameter is supported for connect as of now.

Simple library testing
----------------------
The current tests are not only to test the code, but also to check it in a real environment. Therefore, a good idea,
before we use this library in our own project, is to test its operation with the MQTT broker.

To test if the library works well with your device and MQTT broker,
use the TestMQTT class from the `tests.py` module.

If you don't have your own MQTT broker yet, you can use the free MQTT test broker (test.mosquitto.org).

There is also a sample file `main.py`(`example_test_main.py`),
In this file we add only network configuration. Upload this file to your device with umqtt.simple2_
library and `tests.py` module. Then reset the device and watch the results in the console.

How to get tests up and running quickly:

.. code-block:: bash

    cp example_test_main.py main.py

In the main.py file, assign the appropriate values from your WiFi network to the WIFI_SSID
and WIFI_PASSWORD variables.

.. code-block:: bash

    ./upload_to_device.sh

or

.. code-block:: bash

    ./upload_to_device.sh yes # A compiled version that takes up less memory on devices.

Launching the tests:

.. code-block:: bash

    screen /dev/ttyUSB0  115200 # or screen /dev/ttyACM0  115200
    # Ctrl+D - to restart device


Configuring an encrypted connection with test.mosquitto.org:

.. code-block:: bash

    openssl genrsa -out client.key
    openssl req -out client.csr -key client.key -new
    cat client.csr # Copy and paste on the page: https://test.mosquitto.org/ssl/ , click "submit"
    # Save the certificate to the same directory as client.crt
    # Dowlnoad mosquitto.org.crt
    # Change key formats:
    openssl x509 -in client.crt -out client.crt.der -outform DER
    openssl rsa -in client.key -out client.key.der -outform DER
    openssl x509 -in mosquitto.org.crt -out mosquitto.org.crt.der -outform DER
    # Upload to device
    ampy -d1 --baud 115200 --port /dev/ttyACM0 put ./client.key.der
    ampy -d1 --baud 115200 --port /dev/ttyACM0 put ./client.crt.der
    ampy -d1 --baud 115200 --port /dev/ttyACM0 put ./mosquitto.org.crt.der

Configuring keys for MQTT server(eg. mosquitto):

.. code-block:: bash

    openssl req -new -x509 -days 365 -extensions v3_ca -keyout ca.key -out ca.crt -subj "/C=XX/ST=Home/L=Home/O=MyCA/OU=MyCA/CN=myca"

    openssl genrsa -out server.key 2048
    openssl req -new -out server.csr -key server.key -subj "/C=XX/ST=Home/L=Home/O=MQTT Broker/OU=MQTT Broker/CN=YourMQTTserver"
    openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 365
    openssl rsa -in server.key -out server.key
    openssl rsa -inform pem -in server.pem -outform der -out key.der

Configuring keys for MQTT server(eg. mosquitto):

.. code-block:: bash

    openssl genrsa -out client.key 2048
    openssl req -new -out client.csr -key client.key -subj "/C=XX/ST=Home/L=Home/O=MQTT Client/OU=MQTT Client/CN=YourDeviceHostName"
    openssl x509 -req -in client.csr -CA ../ca.crt -CAkey ../ca.key -CAcreateserial -out client.crt -days 365
    openssl rsa -in client.key -out client.key
    openssl x509 -in client.crt -out client.crt.der -outform DER
    openssl rsa -in client.key -out client.key.der -outform DER
    ampy -d1 --baud 115200 --port /dev/ttyACM0 put ./client.key.der
    ampy -d1 --baud 115200 --port /dev/ttyACM0 put ./client.crt.der

Configuring mosquitto:

.. code-block:: bash

    mosquitto_passwd -c /etc/mosquitto/passwd
    touch /etc/mosquitto/acl

mosquitto.conf

.. code-block::

    per_listener_settings true

    persistence true
    persistence_location /var/lib/mosquitto/
    persistent_client_expiration 4m

    log_dest file /var/log/mosquitto/mosquitto.log
    log_type all

    include_dir /etc/mosquitto/conf.d

    # MQTT, unencrypted, unauthenticated=anonymous
    listener 1883 0.0.0.0
    socket_domain ipv4
    allow_anonymous true
    set_tcp_nodelay true
    #keepalive_interval 0
    max_keepalive 0

    # MQTT, unencrypted, authenticated=password
    listener 1884 0.0.0.0
    socket_domain ipv4
    password_file /etc/mosquitto/passwd
    #acl_file /etc/mosquitto/acl
    set_tcp_nodelay true
    #keepalive 0

    # MQTT, encrypted, unauthenticated
    listener 8883 0.0.0.0
    socket_domain ipv4
    allow_anonymous true
    cafile /etc/mosquitto/certs/ca.crt
    certfile /etc/mosquitto/certs/server.crt
    keyfile /etc/mosquitto/certs/server.key

    # MQTT, encrypted, client certificate required
    listener 8884 0.0.0.0
    socket_domain ipv4
    allow_anonymous true
    cafile /etc/mosquitto/certs/ca.crt
    capath /etc/mosquitto/certs/certs
    certfile /etc/mosquitto/certs/server.crt
    keyfile /etc/mosquitto/certs/server.key
    require_certificate true
    use_identity_as_username true # When set to true it tells mosquitto not to use the password file

    # MQTT, encrypted, authenticated
    listener 8885 0.0.0.0
    socket_domain ipv4
    password_file /etc/mosquitto/passwd
    cafile /etc/mosquitto/certs/ca.crt
    certfile /etc/mosquitto/certs/server.crt
    keyfile /etc/mosquitto/certs/server.key

.. code-block:: bash

    chown -R mosquitto:mosquitto /etc/mosquitto/certs/

Different problems
------------------
* Wrong topic format during subscription - you'll get `OSError: [Errno 104] ECONNRESET` in subscribe()
  or `MQTTException: 1` in the `wait_msg()/check_msg()`

Additional resources
--------------------
* https://mosquitto.org/ - Eclipse Mosquitto is an open source  message broker that implements the MQTT protocol.
* https://test.mosquitto.org/ - MQTT test server
* http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html - MQTT 3.1.1 specyfication
* https://flespi.com/tools/mqtt-board - An open-source MQTT client tool for easy MQTT pub/sub, testing, and demonstration.
* https://github.com/wialon/gmqtt - Python MQTT client implementation(not for the micropython)
* https://www.hivemq.com/mqtt-essentials/ - Blog with explanation of MQTT specifications

.. _umqtt.simple2: https://github.com/fizista/micropython-umqtt.simple2
.. _umqtt.robust2: https://github.com/fizista/micropython-umqtt.robust2
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/fizista/micropython-umqtt.simple2",
    "name": "micropython-umqtt.simple2",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "mqtt micropython",
    "author": "Wojciech Bana\u015b",
    "author_email": "fizista+umqtt.simple2@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/11/55/4e3aa69016568f20b038b9b57a17cca7b9ed72a0ff0a5ef43b41e211e781/micropython-umqtt.simple2-2.2.0.tar.gz",
    "platform": null,
    "description": ".. role:: bash(code)\n   :language: bash\n\n.. role:: python(code)\n   :language: python\n\numqtt.simple2\n=============\n\numqtt.simple2_ is a MQTT client for MicroPython. (Note that it uses some\nMicroPython shortcuts and doesn't work with CPython).\n\nSupport MQTT Version 3.1.1 only.\n\nIt certainly works with micropython ports: esp8266 and esp32. It should also\nwork with other ports, but the library was not tested under other ports.\n\n========  ===========  ========  ===========\n          Micropython\nPort      Version      Normal    SSL\n========  ===========  ========  ===========\nesp8266   1.9.1        OK        Test fails\nesp32     1.9.1        OK        OK\n========  ===========  ========  ===========\n\nMQTT client with more features\n------------------------------\n\nThere's a separate umqtt.robust2_  module which builds\non umqtt.simple2_ adds the ability to reconnect.\nIt is able to send unsent messages itself. And many more...\n\nDifferences between umqtt.simple and umqtt.simple2\n--------------------------------------------------\n* When sending messages from QoS=1, there is no problem with \"suspending\"\n  the script while waiting for confirmation of message receipt by the server.\n* When subscribing to a channel, there is no problem with \"suspending\"\n  the script while waiting for confirmation of the subscription by the server.\n* Information about receiving or failing to receive a message from QoS=1 or subscription\n  can only be received by registering a callback using the :python:`set_callback_status()` method.\n* Currently, the module informs about errors in more detailed way. See the umqtt/errno.py file.\n* The application should also not hang up when using :python:`check_msg()`\n* The code compiled for MPY files, is about 30% larger than the original one.\n  So this library has gained more functionality (maybe reliability),\n  but this was done at the expense of the amount of code.\n\nProblems and solutions\n----------------------\n* ImportError: no module named 'umqtt.simple2'\n\n  Versions of micropython from http://micropython.org/download/ since version 1.12 include\n  the umqtt library, which conflicts with the current library.\n  To avoid conflicts, you need to change the order of importing libraries.\n  You need to import the '/lib' libraries first and then the system libraries.\n  Just add the following lines of code to the boot.py file:\n\n.. code-block:: python\n\n    import sys\n    sys.path.reverse()\n\nHow and where to install this code?\n-----------------------------------\nYou can install using the upip:\n\n.. code-block:: python\n\n    import upip\n    upip.install(\"micropython-umqtt.simple2\")\n\nor\n\n.. code-block:: bash\n\n    micropython -m upip install -p modules micropython-umqtt.simple2\n\n\nYou can also clone this repository, and install it manually:\n\n.. code-block:: bash\n\n    git clone https://github.com/fizista/micropython-umqtt.simple2.git\n\nManual installation gives you more possibilities:\n\n* You can compile this library into MPY files using the :bash:`compile.sh` script.\n* You can remove comments from the code with the command: :bash:`python setup.py minify`\n* You can of course copy the code as it is, if you don't mind.\n\n**Please note that the PyPi repositories contain optimized code (no comments).**\n\nDesign requirements\n-------------------\n\n* Memory efficiency.\n* Avoid infamous design anti-patterns like \"callback hell\".\n* Support for both publishing and subscription via a single client\n  object (another alternative would be to have separate client classes\n  for publishing and subscription).\n\nAPI design\n----------\n\nBased on the requirements above, there are following API traits:\n\n* All data related to MQTT messages is encoded as bytes. This includes\n  both message content AND topic names (even though MQTT spec states\n  that topic name is UTF-8 encoded). The reason for this is simple:\n  what is received over network socket is binary data (bytes) and\n  it would require extra step to convert that to a string, spending\n  memory on that. Note that this applies only to topic names (because\n  they can be both sent and received). Other parameters specified by\n  MQTT as UTF-8 encoded (e.g. ClientID) are accepted as strings.\n* Subscribed messages are delivered via a callback. This is to avoid\n  using a queue for subscribed messages, as otherwise they may be\n  received at any time (including when client expects other type\n  of server response, so there're 2 choices: either deliver them\n  immediately via a callback or queue up until an \"expected\" response\n  arrives). Note that lack of need for a queue is delusive: the\n  runtime call stack forms an implicit queue in this case. And unlike\n  explicit queue, it's much harder to control. This design was chosen\n  because in a common case of processing subscribed messages it's\n  the most efficient. However, if in subscription callback, new\n  messages of QoS>0 are published, this may lead to deep, or\n  infinite recursion (the latter means an application will terminate\n  with :python:`RuntimeException`).\n\nAPI reference\n-------------\n\nTaking into account API traits described above, umqtt pretty closely\nfollows MQTT control operations, and maps them to class methods:\n\n* ``connect(...)`` - Connect to a server. Returns True if this connection\n  uses persisten session stored on a server (this will be always False if\n  clean_session=True argument is used (default)).\n* ``disconnect()`` - Disconnect from a server, release resources.\n* ``ping()`` - Ping server (response is processed automatically by wait_msg()).\n* ``publish()`` - Publish a message.\n* ``subscribe()`` - Subscribe to a topic.\n* ``set_callback()`` - Set callback for received subscription messages. call(topic, msg, retained)\n* ``set_callback_status()`` - Set callback for received subscription messages. call(pid, status)\n* ``set_last_will()`` - Set MQTT \"last will\" message. Should be called\n  *before* connect().\n* ``wait_msg()`` - Wait for a server message. A subscription message will be\n  delivered to a callback set with set_callback(), any other messages\n  will be processed internally.\n* ``check_msg()`` - Check if there's pending message from server. If yes,\n  process the same way as wait_msg(), if not, return immediately.\n\n``wait_msg()`` and ``check_msg()`` are \"main loop iteration\" methods, blocking\nand non-blocking version. They should be called periodically in a loop,\n``wait_msg()`` if you don't have any other foreground tasks to perform\n(i.e. your app just reacts to subscribed MQTT messages), ``check_msg()``\nif you process other foreground tasks too.\n\nNote that you don't need to call ``wait_msg()``/``check_msg()`` if you only\npublish messages with QoS==0, never subscribe to them.\n\nIf you are using a subscription and/or sending QoS>0 messages, you must run one of these\ncommands ( ``wait_msg()`` or ``check_msg()`` ).\n\n**For more detailed information about API please see the source code\n(which is quite short and easy to review) and provided examples.**\n\n\nSupported MQTT features\n-----------------------\n\nQoS 0 and 1 are supported for both publish and subscribe. QoS2 isn't\nsupported to keep code size small. Besides ClientID, only \"clean\nsession\" parameter is supported for connect as of now.\n\nSimple library testing\n----------------------\nThe current tests are not only to test the code, but also to check it in a real environment. Therefore, a good idea,\nbefore we use this library in our own project, is to test its operation with the MQTT broker.\n\nTo test if the library works well with your device and MQTT broker,\nuse the TestMQTT class from the `tests.py` module.\n\nIf you don't have your own MQTT broker yet, you can use the free MQTT test broker (test.mosquitto.org).\n\nThere is also a sample file `main.py`(`example_test_main.py`),\nIn this file we add only network configuration. Upload this file to your device with umqtt.simple2_\nlibrary and `tests.py` module. Then reset the device and watch the results in the console.\n\nHow to get tests up and running quickly:\n\n.. code-block:: bash\n\n    cp example_test_main.py main.py\n\nIn the main.py file, assign the appropriate values from your WiFi network to the WIFI_SSID\nand WIFI_PASSWORD variables.\n\n.. code-block:: bash\n\n    ./upload_to_device.sh\n\nor\n\n.. code-block:: bash\n\n    ./upload_to_device.sh yes # A compiled version that takes up less memory on devices.\n\nLaunching the tests:\n\n.. code-block:: bash\n\n    screen /dev/ttyUSB0  115200 # or screen /dev/ttyACM0  115200\n    # Ctrl+D - to restart device\n\n\nConfiguring an encrypted connection with test.mosquitto.org:\n\n.. code-block:: bash\n\n    openssl genrsa -out client.key\n    openssl req -out client.csr -key client.key -new\n    cat client.csr # Copy and paste on the page: https://test.mosquitto.org/ssl/ , click \"submit\"\n    # Save the certificate to the same directory as client.crt\n    # Dowlnoad mosquitto.org.crt\n    # Change key formats:\n    openssl x509 -in client.crt -out client.crt.der -outform DER\n    openssl rsa -in client.key -out client.key.der -outform DER\n    openssl x509 -in mosquitto.org.crt -out mosquitto.org.crt.der -outform DER\n    # Upload to device\n    ampy -d1 --baud 115200 --port /dev/ttyACM0 put ./client.key.der\n    ampy -d1 --baud 115200 --port /dev/ttyACM0 put ./client.crt.der\n    ampy -d1 --baud 115200 --port /dev/ttyACM0 put ./mosquitto.org.crt.der\n\nConfiguring keys for MQTT server(eg. mosquitto):\n\n.. code-block:: bash\n\n    openssl req -new -x509 -days 365 -extensions v3_ca -keyout ca.key -out ca.crt -subj \"/C=XX/ST=Home/L=Home/O=MyCA/OU=MyCA/CN=myca\"\n\n    openssl genrsa -out server.key 2048\n    openssl req -new -out server.csr -key server.key -subj \"/C=XX/ST=Home/L=Home/O=MQTT Broker/OU=MQTT Broker/CN=YourMQTTserver\"\n    openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 365\n    openssl rsa -in server.key -out server.key\n    openssl rsa -inform pem -in server.pem -outform der -out key.der\n\nConfiguring keys for MQTT server(eg. mosquitto):\n\n.. code-block:: bash\n\n    openssl genrsa -out client.key 2048\n    openssl req -new -out client.csr -key client.key -subj \"/C=XX/ST=Home/L=Home/O=MQTT Client/OU=MQTT Client/CN=YourDeviceHostName\"\n    openssl x509 -req -in client.csr -CA ../ca.crt -CAkey ../ca.key -CAcreateserial -out client.crt -days 365\n    openssl rsa -in client.key -out client.key\n    openssl x509 -in client.crt -out client.crt.der -outform DER\n    openssl rsa -in client.key -out client.key.der -outform DER\n    ampy -d1 --baud 115200 --port /dev/ttyACM0 put ./client.key.der\n    ampy -d1 --baud 115200 --port /dev/ttyACM0 put ./client.crt.der\n\nConfiguring mosquitto:\n\n.. code-block:: bash\n\n    mosquitto_passwd -c /etc/mosquitto/passwd\n    touch /etc/mosquitto/acl\n\nmosquitto.conf\n\n.. code-block::\n\n    per_listener_settings true\n\n    persistence true\n    persistence_location /var/lib/mosquitto/\n    persistent_client_expiration 4m\n\n    log_dest file /var/log/mosquitto/mosquitto.log\n    log_type all\n\n    include_dir /etc/mosquitto/conf.d\n\n    # MQTT, unencrypted, unauthenticated=anonymous\n    listener 1883 0.0.0.0\n    socket_domain ipv4\n    allow_anonymous true\n    set_tcp_nodelay true\n    #keepalive_interval 0\n    max_keepalive 0\n\n    # MQTT, unencrypted, authenticated=password\n    listener 1884 0.0.0.0\n    socket_domain ipv4\n    password_file /etc/mosquitto/passwd\n    #acl_file /etc/mosquitto/acl\n    set_tcp_nodelay true\n    #keepalive 0\n\n    # MQTT, encrypted, unauthenticated\n    listener 8883 0.0.0.0\n    socket_domain ipv4\n    allow_anonymous true\n    cafile /etc/mosquitto/certs/ca.crt\n    certfile /etc/mosquitto/certs/server.crt\n    keyfile /etc/mosquitto/certs/server.key\n\n    # MQTT, encrypted, client certificate required\n    listener 8884 0.0.0.0\n    socket_domain ipv4\n    allow_anonymous true\n    cafile /etc/mosquitto/certs/ca.crt\n    capath /etc/mosquitto/certs/certs\n    certfile /etc/mosquitto/certs/server.crt\n    keyfile /etc/mosquitto/certs/server.key\n    require_certificate true\n    use_identity_as_username true # When set to true it tells mosquitto not to use the password file\n\n    # MQTT, encrypted, authenticated\n    listener 8885 0.0.0.0\n    socket_domain ipv4\n    password_file /etc/mosquitto/passwd\n    cafile /etc/mosquitto/certs/ca.crt\n    certfile /etc/mosquitto/certs/server.crt\n    keyfile /etc/mosquitto/certs/server.key\n\n.. code-block:: bash\n\n    chown -R mosquitto:mosquitto /etc/mosquitto/certs/\n\nDifferent problems\n------------------\n* Wrong topic format during subscription - you'll get `OSError: [Errno 104] ECONNRESET` in subscribe()\n  or `MQTTException: 1` in the `wait_msg()/check_msg()`\n\nAdditional resources\n--------------------\n* https://mosquitto.org/ - Eclipse Mosquitto is an open source  message broker that implements the MQTT protocol.\n* https://test.mosquitto.org/ - MQTT test server\n* http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html - MQTT 3.1.1 specyfication\n* https://flespi.com/tools/mqtt-board - An open-source MQTT client tool for easy MQTT pub/sub, testing, and demonstration.\n* https://github.com/wialon/gmqtt - Python MQTT client implementation(not for the micropython)\n* https://www.hivemq.com/mqtt-essentials/ - Blog with explanation of MQTT specifications\n\n.. _umqtt.simple2: https://github.com/fizista/micropython-umqtt.simple2\n.. _umqtt.robust2: https://github.com/fizista/micropython-umqtt.robust2",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "MQTT client for MicroPython.",
    "version": "2.2.0",
    "split_keywords": [
        "mqtt",
        "micropython"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "9e99cef983db6043e4248f8a93b03a81",
                "sha256": "48fd4da7701b95986293b06d343fbc564ebe7dfa82f5c8c09364c20df755f0e4"
            },
            "downloads": -1,
            "filename": "micropython-umqtt.simple2-2.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9e99cef983db6043e4248f8a93b03a81",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8148,
            "upload_time": "2022-12-23T15:30:03",
            "upload_time_iso_8601": "2022-12-23T15:30:03.116187Z",
            "url": "https://files.pythonhosted.org/packages/11/55/4e3aa69016568f20b038b9b57a17cca7b9ed72a0ff0a5ef43b41e211e781/micropython-umqtt.simple2-2.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-23 15:30:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "fizista",
    "github_project": "micropython-umqtt.simple2",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "micropython-umqtt.simple2"
}
        
Elapsed time: 0.02070s