Keep EMQ X Broker Windows Service running 24/7 with Service Protector

How to Keep your EMQ X Broker Windows Service Running 24/7 with Service Protector

Automatically restart EMQ X Broker whenever it stops, crashes or fails. Ensure that your MQTT broker is always running.

EMQ X Broker is a massively scalable, highly extensible distributed MQTT message broker for IoT and mobile applications.

The MQTT broker can be installed as a service, to ensure that it starts interacting with clients as soon as your machine boots:


To monitor & bulletproof the EMQ X Broker (EMQX) Windows Service with Service Protector:

  1. If necessary, download and setup EMQX.

    Be sure to run "bin\emqx.cmd install" to enable Windows Service operation.

  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, select the EMQ X Broker windows service.

    Since we installed EMQX version 4.29, the service is called emqx_4.2.9 on our system:

    EMQ X Broker Windows Service: General Tab

  6. Move to the Monitor tab. To keep your MQTT broker "fresh" and free of memory leaks and other unwanted accumulations, we recommend establishing a nightly restart of the service.

    To set that up, check the At the following times box, click the Add button and specify when you want the service to be recycled.

    For example, we have opted for a daily restart at 2 AM:

    EMQ X Broker Windows Service: Monitor Tab

    Please feel free to select a weekly restart (during an established maintenance window?) if you think a daily schedule is overkill. Also, consider rebooting the entire operating system if you think that will improve the stability of your environment.

  7. We're done setting up EMQ X Broker so click the Save button to record your settings. In a few seconds, a new entry will show up in the Service Protector window.

    The green shield indicates that Service Protector is already monitoring the EMQX Windows Service, to rapidly detect and react to crashes and other failures:

    EMQ X Broker Windows Service: Protected

  8. That's it! Next time your computer boots, EMQ X Broker will start automatically and Service Protector will babysit the service to promptly restart it if it stops for any reason.

    We encourage you to edit the EMQX entry in Service Protector and browse through the many other settings that may be appropriate for your environment. For example, send an email whenever the service fails, clamp down on RAM or CPU hogging, verify that TCP/IP connections are accepted, and much more.



Trouble protecting the EMQ X Broker Windows Service?