Skip to content

DaemonConfiguration

Kamil Baczkowicz edited this page Jan 14, 2016 · 9 revisions

Sample configuration files

Basic configuration

<?xml version="1.0" encoding="UTF-8"?>
<mqttspydc:MqttSpyDaemonConfiguration xmlns:mqttspydc="http://baczkowicz.pl/mqtt-spy/daemon/configuration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <Connection>
  
	<!-- Port number is optional (default is 1883) -->
	<ServerURI>localhost</ServerURI>
  	  		
  	<!-- Leave empty to auto-generate -->
	<ClientID></ClientID>
			
	<MessageLog>DISABLED</MessageLog>
	
	<!-- Receive messages publish by the sample_publish script -->
	<Subscription topic="mqtt-spy-daemon/#" />
			
	<!-- Publishing sample messages; use the built-in sample -->
	<BackgroundScript>
		<File>/sample-publish.js</File>
	</BackgroundScript>

	<!-- Exit the daemon when the script has finished -->
	<RunningMode>SCRIPTS_ONLY</RunningMode>
  </Connection>
  
</mqttspydc:MqttSpyDaemonConfiguration>

Expanded configuration

Note: you will need to modify this configuration to point at the correct script files.

<?xml version="1.0" encoding="UTF-8"?>
<mqttspydc:MqttSpyDaemonConfiguration xmlns:mqttspydc="http://baczkowicz.pl/mqtt-spy/daemon/configuration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <Connection>
  
	<!-- Optional; to force 3.1 or 3.1.1 use "MQTT 3.1" or "MQTT 3.1.1" respectively -->
  	<Protocol>MQTT Default</Protocol>
  	
	<!-- Server URI should be supplied without any prefix; port number is optional (default is 1883) -->
	<ServerURI>localhost</ServerURI>
  	  	
  	<!-- Optional; set to true to use WebSocket connections (over HTTP) -->
  	<WebSocket>false</WebSocket>
  	
  	<!-- Leave empty to auto-generate -->
	<ClientID></ClientID>
			
	<UserCredentials>
		<Username>test2</Username>
		<!-- Password is base64 encoded -->
		<Password>dGVzdDI=</Password>
	</UserCredentials>
		
	<!-- Payload is base64 encoded -->
	<LastWillAndTestament topic="ltw/mqtt-spy-daemon" qos="0" retained="false">R29pbmcgb2ZmbGluZS4gQnllIGJ5ZS4uLg==</LastWillAndTestament>
									
	<CleanSession>true</CleanSession>
	<ConnectionTimeout>10</ConnectionTimeout>
	<KeepAliveInterval>10</KeepAliveInterval>
			
	<ReconnectionSettings>
		<!-- How long (in ms) to wait after previous connection attempt before trying to connect again -->
		<RetryInterval>5000</RetryInterval>				
		<!-- Whether to resubscribe to all topics when the connection is regained -->
		<Resubscribe>true</Resubscribe>
	</ReconnectionSettings>
			
	<!-- 
		For binary payloads, change it to XML_WITH_ENCODED_PAYLOAD.
				
		To log QoS, Retained flag, connection name or subscription, use:
		logQos="true" logRetained="true" logConnection="true" logSubscription="true" 
	-->
	<MessageLog logBeforeScripts="false">XML_WITH_PLAIN_PAYLOAD</MessageLog>
			
	<Subscription topic="/test/#" qos="0" />
	<!-- Use the script file for things like auto-reply or additional logging -->
	<Subscription topic="/home/#" qos="0" scriptFile="src/test/resources/reply.js" />
			 
	<!-- Use these for publishing messages -->
	<BackgroundScript>
		<File>src/test/resources/bedroom.js</File>
	</BackgroundScript>

	<!-- Use CONTINUOUS or SCRIPTS_ONLY -->
	<RunningMode>SCRIPTS_ONLY</RunningMode>
  </Connection>
  
</mqttspydc:MqttSpyDaemonConfiguration>

Secure connection to test.mosquitto.org

Note: this configuration does nothing apart from establishing a connection and keeping it - used for daemon integration to perform additional actions.

<?xml version="1.0" encoding="UTF-8"?>
<mqttspydc:MqttSpyDaemonConfiguration xmlns:mqttspydc="http://baczkowicz.pl/mqtt-spy/daemon/configuration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <Connection>
  
	<ServerURI>test.mosquitto.org</ServerURI>
  	
	<ClientID>mqtt-spy-daemon</ClientID>
									
	<CleanSession>true</CleanSession>
	<ConnectionTimeout>10</ConnectionTimeout>
	<KeepAliveInterval>10</KeepAliveInterval>
			
	<!-- Optional -->
	<SSL>
		<!-- Available modes are (see https://github.com/kamilfb/mqtt-spy/wiki/TLS for more info): 
			  -	DISABLED 
			  -	BASIC (externally provided values)
			  -	SERVER_ONLY (CertificateAuthorityFile) 
			  -	SERVER_AND_CLIENT (CertificateAuthorityFile, ClientCertificateFile, ClientKeyFile, ClientKeyPassword, ClientKeyPEM [boolean])
			  -	SERVER_KEYSTORE (ServerKeyStoreFile, ServerKeyStorePassword) 
			  -	SERVER_AND_CLIENT_KEYSTORES (ClientKeyPassword, ServerKeyStoreFile, ServerKeyStorePassword, ClientKeyStoreFile, ClientKeyStorePassword)
			  -	PROPERTIES (Property -> Name/Value)
		-->
        <Mode>SERVER_ONLY</Mode>
        <Protocol>TLSv1.2</Protocol>
        <!-- This uses the built-in mosquitto.org certificate file -->
        <CertificateAuthorityFile>/certificates/certificate_authority_files/mosquitto.org.crt</CertificateAuthorityFile>
    </SSL>
	
	<ReconnectionSettings>
		<!-- How long (in ms) to wait after previous connection attempt before trying to connect again -->
		<RetryInterval>5000</RetryInterval>				
		<!-- Whether to resubscribe to all topics when the connection is regained -->
		<Resubscribe>true</Resubscribe>
	</ReconnectionSettings>
			
	<MessageLog>DISABLED</MessageLog>

	<RunningMode>CONTINUOUS</RunningMode>
  </Connection>
  
</mqttspydc:MqttSpyDaemonConfiguration>