MQTT Publish on unconnected MQTT Client
# help
i
If the my code is calling mqtt.publish on a disconnected MQTT Client (I killed the broker to see what happens) it tries to reconnect using the reconnect strategy (default). During this time a publish might happen, which gets blocked until the MQTT Client has connected and then still sends this message. Can I set a timeout for a publish to happen? I moved the publish into a task as well and triggered multiple publish. They all got stuck and have been send once the client came back online. Is there a way to cancel a task after a duration n? (that would be the walkaround for the timout of a publish)
I could think of something like that:
Copy code
task:: 
  publish/Task := task:: 
    client.publish REQUEST_TOPIC payload
    logger.debug "publish has been send"
  sleep --ms=2000
  publish.cancel
f
Typically we use
with_timeout: ...
so:
Copy code
with_timeout --ms=5_000:
  client.publish REQUEST_TOPIC payload