Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] Thinking about health checks for a MQTT client running in a container

Sorry I guess I wasn't clear.  I'm looking for something I can use as the container health check in the Docker file of the MQTT client worker program so that Kubernetes will kill and restart it if it's not available.  The most common health checks in a containerized application involve checking a http endpoint it provides, but in this case I don't have one.

Steve

On Oct 20, 2023 2:47 AM, Denis Dowling via mosquitto-dev <mosquitto-dev@xxxxxxxxxxx> wrote:

Hi Steve,

I have done similar client health checks before using the LWT (Last Will
& Testament) message. When a client starts up it first starts it
subscribes to an channel specific "client health" channel and registers
an LWT message. Periodically the client will publish messages to this
channel with various health information. If the client unexpected
disconnects than the LWT message will be pushed to the channel by the
server. Other interested parties can subscribe to the "client health"
channel at any point to query the client state. In this case you also
need to set the lastWillRetain message so the last known state of the
client is available to other systems.

Regards,
Denis

On 20/10/2023 3:44 pm, Steve Prior via mosquitto-dev wrote:
> I have a bunch of services running in containers which are "pure" MQTT
> clients - the service subscribes to MQTT topics and when it receives a
> message it performs some action.  The service doesn't have an http
> service or a tcp port it's listening on - all its connections are
> outbound.
>
> I'm trying to think about what would make sense as a health check for
> such an application.   I'm not very excited about adding a http
> listener just as a health check endpoint and nothing else. Sending a
> MQTT message to a special health check topic that the service replies
> to may work but I'm not sure there aren't problems there too.
>
> So I'm curious what (if anything) others are doing.  Another thought I
> had is could it be possible to query the mosquitto server about the
> health of the client service's connection to it - the health check is
> does the mosquitto server have a current ping for the MQTT client? 
> It's just a little weird to ask a third party (the mosquitto server)
> about the health of one of it's clients, but maybe not wrong.  I'm
> sure that it gets a little tricky to have that kind of health check
> know the client id which would be needed to query in the mosquitto
> server unless the mqtt client service uses a hardcoded client id
> (which wouldn't be desireable).
>
> Thoughts?
>
> Steve
>
> _______________________________________________
> mosquitto-dev mailing list
> mosquitto-dev@xxxxxxxxxxx
> To unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/mosquitto-dev

_______________________________________________
mosquitto-dev mailing list
mosquitto-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/mosquitto-dev



Back to the top