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;
    }
  }