bluerhinos / phpMQTT

a simple php class to connect/publish/subscribe to a MQTT broker
Other
773 stars 460 forks source link

Mitigate endless loop broken pipe error #143

Open tb205gti opened 1 year ago

tb205gti commented 1 year ago

The code can end up in an endless loop if a broken pipe is experienced in the _fwrite function. This is a rudimentary mitigation by counting the iterations and comparing it to the buffer_length. If the iterations are double the buffer_length, there is a high risk that it is stuck in an endless loop.

PHP Notice:  fwrite(): send of 2013 bytes failed with errno=32 Broken pipe in /phpMQTT.php on line 435