paho.mqtt.embedded-c icon indicating copy to clipboard operation
paho.mqtt.embedded-c copied to clipboard

[C++ client] Parameter errors causes connection drop

Open Novakov opened this issue 8 years ago • 4 comments
trafficstars

I noticed that MQTTClient treats all error conditions the same and handles them closing session. However few errors can be casued by mistake in parameters in which case session is still working properly.

For example:

  1. Call client.subscribe("/test", MQTT::QOS0, nullptr);
  2. Try to publish message - fail with not information about error cause (beside "there was an error")

It's pretty hard to spot the cause-effect relationship between these two actions.

It would be nice to get more precise error codes from MQTTClient, at least to be able to differentiate between parameters error and network-level errors.

Novakov avatar Nov 10 '17 17:11 Novakov

This client is meant to be really lightweight, to use as few resources as possible for when it needs to run on a microprocessor with 16k RAM for instance. Adding more checks takes more resources - that's why they aren't there. More checks could be added in conditional code (MQTT_DEBUG perhaps) sections so that they can be compiled out if preferred.

icraggs avatar Nov 11 '17 17:11 icraggs

The checks are there but all lead to the same result: error code and session close. That way you don't know if you messed up with parameters which is easy to fix or there is something wrong with network stack which is much harder to debug.

Novakov avatar Nov 11 '17 18:11 Novakov