Keep Eclipse Mosquitto Windows Service running 24/7 with Service Protector

How to Keep the Eclipse Mosquitto Windows Service Running 24/7 with Service Protector

Automatically restart Mosquitto Broker when it stops for any reason. Survive crashes, accidental shutdowns and avoid costly downtime.

Eclipse Mosquitto is an open source message broker that implements the IoT-centric MQTT protocol. The Windows implementation leverages a service to automatically start the broker at boot:

To protect the Mosquitto Windows Service with Service Protector:

  1. Download and install Mosquitto, if necessary.

    Be sure to select the service component when installing:

  2. Download and install Service Protector, if necessary.

  3. Start Service Protector.

  4. Select Protector > Add to open the Add Protector window:

    Add Protector

  5. On the General tab, in the Service to protect field, choose Mosquitto Broker.

    You will notice a green circle on the left if Mosquitto is already running, as was the case on our server:

    Mosquitto Broker Windows Service: General Tab

  6. Switch to the Monitor tab. Let's set up a nightly restart of the broker, to keep Mosquitto fresh and free of debilitating resource leaks.

    Check the At the following times box, click the Add button, and specify a "quiet" time to restart the service.

    Sunday mornings at 1 AM works for us:

    Mosquitto Broker Windows Service: Monitor Tab

  7. And if you find that the Mosquitto service takes a while to shut down, switch to the Extras tab and increase the wait time from 1 to 2 minutes:

    Mosquitto Broker Windows Service: Extras Tab

  8. Click the Save button. In a few seconds, an entry for Mosquitto will show up in the Service Protector window. The service is already being protected from failure, as evidenced by the green shield:

    Mosquitto Broker Windows Service: Protected

  9. That's it! Next time your computer boots, Mosquitto will start automatically and Service Protector will watch the service to quickly restart it if it stops for any reason.

    We encourage you to edit Mosquitto Broker in Service Protector and check out the many other settings that may be appropriate for your environment. For example, send an email when the service fails, run a batch file to clean up before restarting the service, and much more.



Trouble protecting the Mosquitto Broker Windows Service?