arduino-libraries / ArduinoMqttClient

ArduinoMqttClient Library for Arduino
GNU Lesser General Public License v2.1
187 stars 73 forks source link

Wrong condition for stopping a connection on endMessage #53

Open JDuchniewicz opened 3 years ago

JDuchniewicz commented 3 years ago

For secure connections where the Client is served over SSL, the message size is slightly greater and the below assert fails. I replaced the != condition with < so that it fails only when message could not be send in full.

int MqttClient::endMessage()
{
  if (!_txStreamPayload) {
    if (!publishHeader(_txPayloadBufferIndex) ||
        (clientWrite(_txPayloadBuffer, _txPayloadBufferIndex) != _txPayloadBufferIndex)) {
      stop();

      return 0;
    }
  }
aentinger commented 3 years ago

Hi @JDuchniewicz :wave: ☕ Could you get me a diff (or even better a PR)?

JDuchniewicz commented 3 years ago

Submitted a PR, please check at your convenience @aentinger