Skip to content

Releases: php-mqtt/client

Improved TLS options, access to the ping schedule & protocol encoding fixes

02 Aug 13:19
0d27b1d
Compare
Choose a tag to compare

Major improvements regarding new TLS options have been made in #24. It is now possible to use TLS without providing a CA file and peer verification can be toggled based on individual needs. Also establishing the connection should now be more reliable, since first a normal TCP connection is established, for which then TLS is enabled afterwards based on the defined settings. Note: for backwards compatibility, $useTls of the connection settings is also enabled if a CA file is configured.

For use cases with an external loop, where the MQTT client is run besides some other code, a new protected getter nextPingAt() has been added to the MQTTClient class. If you need access to this method, you should inherit your own client implementation. Details can be found in #21.

To avoid busy waiting when reading from the socket connection in blocking mode, the configured $socketTimeout is now taken into account and the readFromSocket($limit, $withoutBlocking) method will exit with an exception after the configured amount of seconds. The changes are quite compact and can be found in #29.

The way message contents (e.g. topic names) were encoded when publishing messages and subscribing to topics could lead to issues in previous versions. #30 fixes this by always encoding messages according to the specification.

Last but not least, some parts of the code have been normalized in respect of code style (#22). A consistent code style for pull requests is now enforced using a workflow (#23).

Fix: pass retain flag to subscription callbacks & allow access to raw socket using inheritance

26 Jul 09:09
803d664
Compare
Choose a tag to compare

As pointed out and fixed in #19, the retain flag sent by the broker has not been passed to subscription callbacks. This flag indicates whether a message is received because it has been retained by the broker or if it was delivered live (in case of $retained === false), after subscribing to a topic. Having this information can be used to detect stale messages for example. A good summary on retained messages can be found on the HiveMQ blog.

Due to the change made in #9, it is now possible to access the raw socket from own implementations of the MQTTClient when using inheritance. This may be handy if one needs to work with multiple clients and stream_select().

Minor changes to the code style have been pushed in #20.

Fix: use addition to increase message size

01 Jul 19:09
92f01cf
Compare
Choose a tag to compare

As pointed out in #6, when using a username and password to connect to a broker, the message size has been manipulated using string concatenation instead of mathematical addition. This caused an issue with chr() expecting an integer and not a string. It also would have lead to wrong information being sent.

Usernames and passwords should now be correctly encoded during the connection handshake. Thanks to @sten for pointing out this oversight!

Fix: reset keep alive timer only when sending data to the broker

19 Jun 13:00
e4b5f47
Compare
Choose a tag to compare

The MQTT v3.1 specification states that clients need to send at least one data-related message within the defined Keep Alive Interval (which is returned by the broker during the connection handshake). If no such message has been sent, the client MUST send a PINGREQ instead. Otherwise, the broker closes the connection.

Due to the way the MQTT client was resetting the ping timer whenever a message was received from the broker, subscribe-only applications utilizing the QoS Level 0 could run into disconnects. This happened because the client never sent an acknowledgement for the QoS 0 messages and also never sent a Ping Request because the Keep Alive Timer was reset on every received published messages.

This patch fixes the issue by resetting the Keep Alive Timer only whenever data is sent to the broker. More details in #5.

Fix: writing to socket throws PHP notice when the socket has been closed by the server

15 Feb 09:03
359c5e2
Compare
Choose a tag to compare

Unfortunately, PHP will simply throw a PHP notice (which cannot be catched) when we use fwrite() on a socket and the connection has been closed by the server. To leverage the already in place error handling of the MQTTClient, we suppress potential PHP notices, warnings and errors when using fwrite().

Fix: TypeError thrown when creating MQTTClient without $clientId argument

14 Feb 18:12
2c00807
Compare
Choose a tag to compare

In this release, an issue with declare(strict_types=1) has been fixed. Constructing a new MQTTClient instance without the $clientId argument caused a unique id to be generated. Unfortunately, the generateRandomClientId() method was missing a cast. More details can be found in the PR #1.