mosquitto 0.2 → 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@
2
2
  #define MOSQUITTO_CLIENT_H
3
3
 
4
4
  typedef struct mosquitto_callback_t mosquitto_callback_t;
5
+ typedef struct mosquitto_callback_waiting_t mosquitto_callback_waiting_t;
5
6
 
6
7
  typedef struct {
7
8
  struct mosquitto *mosq;
@@ -15,6 +16,7 @@ typedef struct {
15
16
  VALUE callback_thread;
16
17
  pthread_mutex_t callback_mutex;
17
18
  pthread_cond_t callback_cond;
19
+ mosquitto_callback_waiting_t *waiter;
18
20
  mosquitto_callback_t *callback_queue;
19
21
  } mosquitto_client_wrapper;
20
22
 
@@ -23,6 +25,16 @@ typedef struct {
23
25
  Data_Get_Struct(obj, mosquitto_client_wrapper, client); \
24
26
  if (!client) rb_raise(rb_eTypeError, "uninitialized Mosquitto client!");
25
27
 
28
+ #define RetryNotConnectedOnce() \
29
+ if (retried == false) { \
30
+ mosquitto_reconnect(client->mosq); \
31
+ time.tv_sec = 0; \
32
+ time.tv_usec = 300 * 1000; \
33
+ rb_thread_wait_for(time); \
34
+ retried = true; \
35
+ goto retry_once; \
36
+ }
37
+
26
38
  #define MosquittoAssertCallback(cb, arity) \
27
39
  if (NIL_P(cb)){ \
28
40
  cb = proc; \
@@ -90,10 +102,8 @@ struct mosquitto_callback_t {
90
102
  mosquitto_callback_t *next;
91
103
  };
92
104
 
93
- typedef struct mosquitto_callback_waiting_t mosquitto_callback_waiting_t;
94
105
  struct mosquitto_callback_waiting_t {
95
106
  mosquitto_callback_t *callback;
96
- mosquitto_client_wrapper *client;
97
107
  bool abort;
98
108
  };
99
109
 
@@ -4,17 +4,36 @@ RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
4
4
 
5
5
  dir_config('mosquitto')
6
6
 
7
+ def error(message)
8
+ STDERR.puts "\n\n"
9
+ STDERR.puts "***************************************************************************************"
10
+ STDERR.puts "*************** #{message} ***************"
11
+ STDERR.puts "***************************************************************************************"
12
+ exit(1)
13
+ end
14
+
7
15
  # detect homebrew installs, via @brianmario
8
16
  if !have_library 'mosquitto'
9
- base = if !`which brew`.empty?
10
- `brew --prefix`.strip
11
- elsif File.exists?("/usr/local/Cellar/mosquitto")
12
- '/usr/local/Cellar'
13
- end
14
-
15
- if base and mosquitto = Dir[File.join(base, 'Cellar/mosquitto/*')].sort.last
16
- $INCFLAGS << " -I#{mosquitto}/include "
17
- $LDFLAGS << " -L#{mosquitto}/lib "
17
+ if RUBY_PLATFORM =~ /darwin/
18
+ brew_exec_path = `which brew`
19
+ base = if !brew_exec_path.empty?
20
+ brew_exec_path.chomp!
21
+ brew_exec_path = File.readlink(brew_exec_path) if File.symlink?(brew_exec_path)
22
+ File.expand_path(File.join(brew_exec_path, "..", ".."))
23
+ elsif File.exists?("/usr/local/Cellar/mosquitto")
24
+ '/usr/local/Cellar'
25
+ end
26
+
27
+ if base and mosquitto = Dir[File.join(base, 'Cellar/mosquitto/*')].sort.last
28
+ $INCFLAGS << " -I#{mosquitto}/include "
29
+ $LDFLAGS << " -L#{mosquitto}/lib "
30
+ else
31
+ error("libmosquitto required - install homebrew (http://brew.sh/) and run 'brew install mosquitto'")
32
+ end
33
+ elsif RUBY_PLATFORM =~ /linux/
34
+ error("libmosquitto required - see https://github.com/xively/mosquitto#linux-ubuntu and https://github.com/xively/mosquitto#building-libmosquitto-from-source")
35
+ else
36
+ error("libmosquitto required - please see http://mosquitto.org/download/ for installation instructions for your platform (#{RUBY_PLATFORM})")
18
37
  end
19
38
  end
20
39
 
@@ -28,4 +47,4 @@ $defs << "-pedantic"
28
47
  $CFLAGS << ' -Wall -funroll-loops'
29
48
  $CFLAGS << ' -Wextra -O0 -ggdb3' if ENV['DEBUG']
30
49
 
31
- create_makefile('mosquitto_ext')
50
+ create_makefile('mosquitto_ext')
@@ -5,8 +5,8 @@
5
5
  #define RFLOAT_VALUE(v) (RFLOAT(v)->value)
6
6
  #endif
7
7
 
8
- #if LIBMOSQUITTO_VERSION_NUMBER != 1002003
9
- #error libmosquitto version 1.2.3 required
8
+ #if LIBMOSQUITTO_VERSION_NUMBER != 1003001
9
+ #error libmosquitto version 1.3.1 required
10
10
  #endif
11
11
 
12
12
  #ifdef RUBINIUS
@@ -5,4 +5,26 @@ require 'mosquitto/logging'
5
5
 
6
6
  class Mosquitto::Client
7
7
  include Mosquitto::Logging
8
+
9
+ if RUBY_VERSION.split(".").first == '2'
10
+ def wait_readable(timeout = 10)
11
+ retries ||= 0
12
+ IO.for_fd(socket).wait_readable(timeout) && sleep(2)
13
+ rescue Errno::EBADF
14
+ retries += 1
15
+ sleep 0.5
16
+ raise if retries > 4
17
+ retry
18
+ end
19
+ else
20
+ def wait_readable(timeout = 10)
21
+ retries ||= 0
22
+ IO.for_fd(socket).wait(timeout) && sleep(2)
23
+ rescue Errno::EBADF
24
+ retries += 1
25
+ sleep 0.5
26
+ raise if retries > 4
27
+ retry
28
+ end
29
+ end
8
30
  end
@@ -9,9 +9,11 @@ module Mosquitto::Logging
9
9
  Mosquitto::LOG_DEBUG => Logger::DEBUG
10
10
  }
11
11
 
12
+ attr_reader :logger
13
+
12
14
  # Pipes libmosquitto log messages to a Ruby logger instance.
13
15
  #
14
- # @param logger [String] a Ruby logger instance. Compatible with SyslogLogger and other
16
+ # @param logger [Logger] a Ruby logger instance. Compatible with SyslogLogger and other
15
17
  # implementations as well.
16
18
  # @raise [Argument] on invalid input params
17
19
  # @example
@@ -26,7 +28,18 @@ module Mosquitto::Logging
26
28
 
27
29
  on_log do |level, message|
28
30
  severity = LOG_LEVELS[level] || Logger::UNKNOWN
29
- @logger.add(severity, message.to_s, "MQTT")
31
+ logger.add(severity, message.to_s, "MQTT")
30
32
  end
31
33
  end
34
+
35
+ # Pipe debug messages through an already assigned logger instance.
36
+ #
37
+ # @param message [string] a message to log
38
+ # @param severity [Mosquitto::LOG_ERR, Mosquitto::LOG_WARNING, Mosquitto::LOG_INFO, Mosquitto::LOG_DEBUG] log severity
39
+ # @example
40
+ # client.log("message")
41
+ #
42
+ def log(message, severity = Logger::DEBUG)
43
+ logger.add(severity, message.to_s, "MQTT") if logger
44
+ end
32
45
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Mosquitto
4
- VERSION = "0.2"
4
+ VERSION = "0.3"
5
5
  end
@@ -8,30 +8,21 @@ require 'io/wait'
8
8
  require 'timeout'
9
9
 
10
10
  Thread.abort_on_exception = true
11
-
12
- class Mosquitto::Client
13
- if RUBY_VERSION.split(".").first == '2'
14
- def wait_readable(timeout = 15)
15
- IO.for_fd(socket).wait_readable(timeout)
16
- end
17
- else
18
- def wait_readable(timeout = 15)
19
- IO.for_fd(socket).wait(timeout)
20
- end
21
- end
22
- end
11
+ STDOUT.sync
23
12
 
24
13
  class MosquittoTestCase < Test::Unit::TestCase
25
- TEST_HOST = "test.mosquitto.org"
14
+ TEST_HOST = "localhost"
26
15
  TEST_PORT = 1883
27
16
 
28
- TLS_TEST_HOST = "test.mosquitto.org"
17
+ TLS_TEST_HOST = "localhost"
29
18
  TLS_TEST_PORT = 8883
19
+ TIMEOUT = 240
30
20
 
31
21
  undef_method :default_test if method_defined? :default_test
32
22
 
33
23
  def wait(&condition)
34
- Timeout.timeout(5) do
24
+ sleep 1
25
+ Timeout.timeout(10) do
35
26
  loop do
36
27
  sleep(0.2)
37
28
  break if condition.call
@@ -0,0 +1,734 @@
1
+ # Config file for mosquitto
2
+ #
3
+ # See mosquitto.conf(5) for more information.
4
+ #
5
+ # Default values are shown, uncomment to change.
6
+ #
7
+ # Use the # character to indicate a comment, but only if it is the
8
+ # very first character on the line.
9
+
10
+ # =================================================================
11
+ # General configuration
12
+ # =================================================================
13
+
14
+ # Time in seconds to wait before resending an outgoing QoS=1 or
15
+ # QoS=2 message.
16
+ #retry_interval 20
17
+
18
+ # Time in seconds between updates of the $SYS tree.
19
+ #sys_interval 10
20
+
21
+ # Time in seconds between cleaning the internal message store of
22
+ # unreferenced messages. Lower values will result in lower memory
23
+ # usage but more processor time, higher values will have the
24
+ # opposite effect.
25
+ # Setting a value of 0 means the unreferenced messages will be
26
+ # disposed of as quickly as possible.
27
+ #store_clean_interval 10
28
+
29
+ # Write process id to a file. Default is a blank string which means
30
+ # a pid file shouldn't be written.
31
+ # This should be set to /var/run/mosquitto.pid if mosquitto is
32
+ # being run automatically on boot with an init script and
33
+ # start-stop-daemon or similar.
34
+ #pid_file
35
+
36
+ # When run as root, drop privileges to this user and its primary
37
+ # group.
38
+ # Leave blank to stay as root, but this is not recommended.
39
+ # If run as a non-root user, this setting has no effect.
40
+ # Note that on Windows this has no effect and so mosquitto should
41
+ # be started by the user you wish it to run as.
42
+ #user mosquitto
43
+
44
+ # The maximum number of QoS 1 and 2 messages currently inflight per
45
+ # client.
46
+ # This includes messages that are partway through handshakes and
47
+ # those that are being retried. Defaults to 20. Set to 0 for no
48
+ # maximum. Setting to 1 will guarantee in-order delivery of QoS 1
49
+ # and 2 messages.
50
+ #max_inflight_messages 20
51
+
52
+ # The maximum number of QoS 1 and 2 messages to hold in a queue
53
+ # above those that are currently in-flight. Defaults to 100. Set
54
+ # to 0 for no maximum (not recommended).
55
+ # See also queue_qos0_messages.
56
+ #max_queued_messages 100
57
+
58
+ # Set to true to queue messages with QoS 0 when a persistent client is
59
+ # disconnected. These messages are included in the limit imposed by
60
+ # max_queued_messages.
61
+ # Defaults to false.
62
+ # Note that the MQTT v3.1 spec states that only QoS 1 and 2 messages
63
+ # should be saved in this situation so this is a non-standard option.
64
+ #queue_qos0_messages false
65
+
66
+ # This option sets the maximum publish payload size that the broker will allow.
67
+ # Received messages that exceed this size will not be accepted by the broker.
68
+ # The default value is 0, which means that all valid MQTT messages are
69
+ # accepted. MQTT imposes a maximum payload size of 268435455 bytes.
70
+ #message_size_limit 0
71
+
72
+ # This option allows persistent clients (those with clean session set to false)
73
+ # to be removed if they do not reconnect within a certain time frame. This is a
74
+ # non-standard option. As far as the MQTT spec is concerned, persistent clients
75
+ # persist forever.
76
+ # Badly designed clients may set clean session to false whilst using a randomly
77
+ # generated client id. This leads to persistent clients that will never
78
+ # reconnect. This option allows these clients to be removed.
79
+ #
80
+ # The expiration period should be an integer followed by one of d w m y for
81
+ # day, week, month and year respectively. For example
82
+ #
83
+ # persistent_client_expiration 2m
84
+ # persistent_client_expiration 14d
85
+ # persistent_client_expiration 1y
86
+ #
87
+ # As this is a non-standard option, the default if not set is to never expire
88
+ # persistent clients.
89
+ #persistent_client_expiration
90
+
91
+ # If a client is subscribed to multiple subscriptions that overlap, e.g. foo/#
92
+ # and foo/+/baz , then MQTT expects that when the broker receives a message on
93
+ # a topic that matches both subscriptions, such as foo/bar/baz, then the client
94
+ # should only receive the message once.
95
+ # Mosquitto keeps track of which clients a message has been sent to in order to
96
+ # meet this requirement. The allow_duplicate_messages option allows this
97
+ # behaviour to be disabled, which may be useful if you have a large number of
98
+ # clients subscribed to the same set of topics and are very concerned about
99
+ # minimising memory usage.
100
+ # It can be safely set to true if you know in advance that your clients will
101
+ # never have overlapping subscriptions, otherwise your clients must be able to
102
+ # correctly deal with duplicate messages even when then have QoS=2.
103
+ #allow_duplicate_messages false
104
+
105
+ # The MQTT specification requires that the QoS of a message delivered to a
106
+ # subscriber is never upgraded to match the QoS of the subscription. Enabling
107
+ # this option changes this behaviour. If upgrade_outgoing_qos is set true,
108
+ # messages sent to a subscriber will always match the QoS of its subscription.
109
+ # This is a non-standard option not provided for by the spec.
110
+ #upgrade_outgoing_qos false
111
+
112
+ # =================================================================
113
+ # Default listener
114
+ # =================================================================
115
+
116
+ # IP address/hostname to bind the default listener to. If not
117
+ # given, the default listener will not be bound to a specific
118
+ # address and so will be accessible to all network interfaces.
119
+ # bind_address ip-address/host name
120
+ #bind_address
121
+
122
+ # Port to use for the default listener.
123
+ #port 1883
124
+
125
+ # The maximum number of client connections to allow. This is
126
+ # a per listener setting.
127
+ # Default is -1, which means unlimited connections.
128
+ # Note that other process limits mean that unlimited connections
129
+ # are not really possible. Typically the default maximum number of
130
+ # connections possible is around 1024.
131
+ #max_connections -1
132
+
133
+ # -----------------------------------------------------------------
134
+ # Certificate based SSL/TLS support
135
+ # -----------------------------------------------------------------
136
+ # The following options can be used to enable SSL/TLS support for
137
+ # this listener. Note that the recommended port for MQTT over TLS
138
+ # is 8883, but this must be set manually.
139
+ #
140
+ # See also the mosquitto-tls man page.
141
+
142
+ # At least one of cafile or capath must be defined. They both
143
+ # define methods of accessing the PEM encoded Certificate
144
+ # Authority certificates that have signed your server certificate
145
+ # and that you wish to trust.
146
+ # cafile defines the path to a file containing the CA certificates.
147
+ # capath defines a directory that will be searched for files
148
+ # containing the CA certificates. For capath to work correctly, the
149
+ # certificate files must have ".crt" as the file ending and you must run
150
+ # "c_rehash <path to capath>" each time you add/remove a certificate.
151
+ #cafile
152
+ #capath
153
+
154
+ # Path to the PEM encoded server certificate.
155
+ #certfile
156
+
157
+ # Path to the PEM encoded keyfile.
158
+ #keyfile
159
+
160
+ # This option defines the version of the TLS protocol to use for this listener.
161
+ # The default value will always be the highest version that is available for
162
+ # the version of openssl that the broker was compiled against. For openssl >=
163
+ # 1.0.1 the valid values are tlsv1.2 tlsv1.1 and tlsv1. For openssl < 1.0.1 the
164
+ # valid values are tlsv1.
165
+ #tls_version
166
+
167
+ # By default a TLS enabled listener will operate in a similar fashion to a
168
+ # https enabled web server, in that the server has a certificate signed by a CA
169
+ # and the client will verify that it is a trusted certificate. The overall aim
170
+ # is encryption of the network traffic. By setting require_certificate to true,
171
+ # the client must provide a valid certificate in order for the network
172
+ # connection to proceed. This allows access to the broker to be controlled
173
+ # outside of the mechanisms provided by MQTT.
174
+ #require_certificate false
175
+
176
+ # If require_certificate is true, you may set use_identity_as_username to true
177
+ # to use the CN value from the client certificate as a username. If this is
178
+ # true, the password_file option will not be used for this listener.
179
+ #use_identity_as_username false
180
+
181
+ # If you have require_certificate set to true, you can create a certificate
182
+ # revocation list file to revoke access to particular client certificates. If
183
+ # you have done this, use crlfile to point to the PEM encoded revocation file.
184
+ #crlfile
185
+
186
+ # If you wish to control which encryption ciphers are used, use the ciphers
187
+ # option. The list of available ciphers can be optained using the "openssl
188
+ # ciphers" command and should be provided in the same format as the output of
189
+ # that command.
190
+ #ciphers
191
+
192
+ # -----------------------------------------------------------------
193
+ # Pre-shared-key based SSL/TLS support
194
+ # -----------------------------------------------------------------
195
+ # The following options can be used to enable PSK based SSL/TLS support for
196
+ # this listener. Note that the recommended port for MQTT over TLS is 8883, but
197
+ # this must be set manually.
198
+ #
199
+ # See also the mosquitto-tls man page and the "Certificate based SSL/TLS
200
+ # support" section. Only one of certificate or PSK encryption support can be
201
+ # enabled for any listener.
202
+
203
+ # The psk_hint option enables pre-shared-key support for this listener and also
204
+ # acts as an identifier for this listener. The hint is sent to clients and may
205
+ # be used locally to aid authentication. The hint is a free form string that
206
+ # doesn't have much meaning in itself, so feel free to be creative.
207
+ # If this option is provided, see psk_file to define the pre-shared keys to be
208
+ # used or create a security plugin to handle them.
209
+ #psk_hint
210
+
211
+ # Set use_identity_as_username to have the psk identity sent by the client used
212
+ # as its username. Authentication will be carried out using the PSK rather than
213
+ # the MQTT username/password and so password_file will not be used for this
214
+ # listener.
215
+ #use_identity_as_username false
216
+
217
+ # When using PSK, the encryption ciphers used will be chosen from the list of
218
+ # available PSK ciphers. If you want to control which ciphers are available,
219
+ # use the "ciphers" option. The list of available ciphers can be optained
220
+ # using the "openssl ciphers" command and should be provided in the same format
221
+ # as the output of that command.
222
+ #ciphers
223
+
224
+ # =================================================================
225
+ # Extra listeners
226
+ # =================================================================
227
+
228
+ # Listen on a port/ip address combination. By using this variable
229
+ # multiple times, mosquitto can listen on more than one port. If
230
+ # this variable is used and neither bind_address nor port given,
231
+ # then the default listener will not be started.
232
+ # The port number to listen on must be given. Optionally, an ip
233
+ # address or host name may be supplied as a second argument. In
234
+ # this case, mosquitto will attempt to bind the listener to that
235
+ # address and so restrict access to the associated network and
236
+ # interface. By default, mosquitto will listen on all interfaces.
237
+ # listener port-number [ip address/host name]
238
+ listener 1883
239
+ listener 8883
240
+
241
+ # The maximum number of client connections to allow. This is
242
+ # a per listener setting.
243
+ # Default is -1, which means unlimited connections.
244
+ # Note that other process limits mean that unlimited connections
245
+ # are not really possible. Typically the default maximum number of
246
+ # connections possible is around 1024.
247
+ #max_connections -1
248
+
249
+ # The listener can be restricted to operating within a topic hierarchy using
250
+ # the mount_point option. This is achieved be prefixing the mount_point string
251
+ # to all topics for any clients connected to this listener. This prefixing only
252
+ # happens internally to the broker; the client will not see the prefix.
253
+ #mount_point
254
+
255
+ # -----------------------------------------------------------------
256
+ # Certificate based SSL/TLS support
257
+ # -----------------------------------------------------------------
258
+ # The following options can be used to enable certificate based SSL/TLS support
259
+ # for this listener. Note that the recommended port for MQTT over TLS is 8883,
260
+ # but this must be set manually.
261
+ #
262
+ # See also the mosquitto-tls man page and the "Pre-shared-key based SSL/TLS
263
+ # support" section. Only one of certificate or PSK encryption support can be
264
+ # enabled for any listener.
265
+
266
+ # At least one of cafile or capath must be defined to enable certificate based
267
+ # TLS encryption. They both define methods of accessing the PEM encoded
268
+ # Certificate Authority certificates that have signed your server certificate
269
+ # and that you wish to trust.
270
+ # cafile defines the path to a file containing the CA certificates.
271
+ # capath defines a directory that will be searched for files
272
+ # containing the CA certificates. For capath to work correctly, the
273
+ # certificate files must have ".crt" as the file ending and you must run
274
+ # "c_rehash <path to capath>" each time you add/remove a certificate.
275
+ cafile <%= ENV['TRAVIS_BUILD_DIR'] %>/test/ssl/all-ca.crt
276
+ # capath
277
+
278
+ # Path to the PEM encoded server certificate.
279
+ certfile <%= ENV['TRAVIS_BUILD_DIR'] %>/test/ssl/server.crt
280
+
281
+ # Path to the PEM encoded keyfile.
282
+ keyfile <%= ENV['TRAVIS_BUILD_DIR'] %>/test/ssl/server.key
283
+
284
+ # By default an TLS enabled listener will operate in a similar fashion to a
285
+ # https enabled web server, in that the server has a certificate signed by a CA
286
+ # and the client will verify that it is a trusted certificate. The overall aim
287
+ # is encryption of the network traffic. By setting require_certificate to true,
288
+ # the client must provide a valid certificate in order for the network
289
+ # connection to proceed. This allows access to the broker to be controlled
290
+ # outside of the mechanisms provided by MQTT.
291
+ require_certificate true
292
+
293
+ #tls_version tlsv1.2
294
+
295
+ # If require_certificate is true, you may set use_identity_as_username to true
296
+ # to use the CN value from the client certificate as a username. If this is
297
+ # true, the password_file option will not be used for this listener.
298
+ #use_identity_as_username false
299
+
300
+ # If you have require_certificate set to true, you can create a certificate
301
+ # revocation list file to revoke access to particular client certificates. If
302
+ # you have done this, use crlfile to point to the PEM encoded revocation file.
303
+ #crlfile
304
+
305
+ # If you wish to control which encryption ciphers are used, use the ciphers
306
+ # option. The list of available ciphers can be optained using the "openssl
307
+ # ciphers" command and should be provided in the same format as the output of
308
+ # that command.
309
+ #ciphers
310
+
311
+ # -----------------------------------------------------------------
312
+ # Pre-shared-key based SSL/TLS support
313
+ # -----------------------------------------------------------------
314
+ # The following options can be used to enable PSK based SSL/TLS support for
315
+ # this listener. Note that the recommended port for MQTT over TLS is 8883, but
316
+ # this must be set manually.
317
+ #
318
+ # See also the mosquitto-tls man page and the "Certificate based SSL/TLS
319
+ # support" section. Only one of certificate or PSK encryption support can be
320
+ # enabled for any listener.
321
+
322
+ # The psk_hint option enables pre-shared-key support for this listener and also
323
+ # acts as an identifier for this listener. The hint is sent to clients and may
324
+ # be used locally to aid authentication. The hint is a free form string that
325
+ # doesn't have much meaning in itself, so feel free to be creative.
326
+ # If this option is provided, see psk_file to define the pre-shared keys to be
327
+ # used or create a security plugin to handle them.
328
+ #psk_hint
329
+
330
+ # Set use_identity_as_username to have the psk identity sent by the client used
331
+ # as its username. Authentication will be carried out using the PSK rather than
332
+ # the MQTT username/password and so password_file will not be used for this
333
+ # listener.
334
+ #use_identity_as_username false
335
+
336
+ # When using PSK, the encryption ciphers used will be chosen from the list of
337
+ # available PSK ciphers. If you want to control which ciphers are available,
338
+ # use the "ciphers" option. The list of available ciphers can be optained
339
+ # using the "openssl ciphers" command and should be provided in the same format
340
+ # as the output of that command.
341
+ #ciphers
342
+
343
+ # =================================================================
344
+ # Persistence
345
+ # =================================================================
346
+
347
+ # If persistence is enabled, save the in-memory database to disk
348
+ # every autosave_interval seconds. If set to 0, the persistence
349
+ # database will only be written when mosquitto exits. See also
350
+ # autosave_on_changes.
351
+ # Note that writing of the persistence database can be forced by
352
+ # sending mosquitto a SIGUSR1 signal.
353
+ #autosave_interval 1800
354
+
355
+ # If true, mosquitto will count the number of subscription changes, retained
356
+ # messages received and queued messages and if the total exceeds
357
+ # autosave_interval then the in-memory database will be saved to disk.
358
+ # If false, mosquitto will save the in-memory database to disk by treating
359
+ # autosave_interval as a time in seconds.
360
+ #autosave_on_changes false
361
+
362
+ # Save persistent message data to disk (true/false).
363
+ # This saves information about all messages, including
364
+ # subscriptions, currently in-flight messages and retained
365
+ # messages.
366
+ # retained_persistence is a synonym for this option.
367
+ #persistence false
368
+
369
+ # The filename to use for the persistent database, not including
370
+ # the path.
371
+ #persistence_file mosquitto.db
372
+
373
+ # Location for persistent database. Must include trailing /
374
+ # Default is an empty string (current directory).
375
+ # Set to e.g. /var/lib/mosquitto/ if running as a proper service on Linux or
376
+ # similar.
377
+ #persistence_location
378
+
379
+ # =================================================================
380
+ # Logging
381
+ # =================================================================
382
+
383
+ # Places to log to. Use multiple log_dest lines for multiple
384
+ # logging destinations.
385
+ # Possible destinations are: stdout stderr syslog topic file
386
+ #
387
+ # stdout and stderr log to the console on the named output.
388
+ #
389
+ # syslog uses the userspace syslog facility which usually ends up
390
+ # in /var/log/messages or similar.
391
+ #
392
+ # topic logs to the broker topic '$SYS/broker/log/<severity>',
393
+ # where severity is one of D, E, W, N, I, M which are debug, error,
394
+ # warning, notice, information and message. Message type severity is used by
395
+ # the subscribe/unsubscribe log_types and publishes log messages to
396
+ # $SYS/broker/log/M/susbcribe or $SYS/broker/log/M/unsubscribe.
397
+ #
398
+ # The file destination requires an additional parameter which is the file to be
399
+ # logged to, e.g. "log_dest file /var/log/mosquitto.log". The file will be
400
+ # closed and reopened when the broker receives a HUP signal. Only a single file
401
+ # destination may be configured.
402
+ #
403
+ # Note that if the broker is running as a Windows service it will default to
404
+ # "log_dest none" and neither stdout nor stderr logging is available.
405
+ # Use "log_dest none" if you wish to disable logging.
406
+ #log_dest stderr
407
+
408
+ # Types of messages to log. Use multiple log_type lines for logging
409
+ # multiple types of messages.
410
+ # Possible types are: debug, error, warning, notice, information,
411
+ # none, subscribe, unsubscribe, all.
412
+ # Note that debug type messages are for decoding the incoming/outgoing
413
+ # network packets. They are not logged in "topics".
414
+ #log_type error
415
+ #log_type warning
416
+ #log_type notice
417
+ #log_type information
418
+
419
+ # If set to true, client connection and disconnection messages will be included
420
+ # in the log.
421
+ #connection_messages true
422
+
423
+ # If set to true, add a timestamp value to each log message.
424
+ #log_timestamp true
425
+
426
+ # =================================================================
427
+ # Security
428
+ # =================================================================
429
+
430
+ # If set, only clients that have a matching prefix on their
431
+ # clientid will be allowed to connect to the broker. By default,
432
+ # all clients may connect.
433
+ # For example, setting "secure-" here would mean a client "secure-
434
+ # client" could connect but another with clientid "mqtt" couldn't.
435
+ #clientid_prefixes
436
+
437
+ # Boolean value that determines whether clients that connect
438
+ # without providing a username are allowed to connect. If set to
439
+ # false then a password file should be created (see the
440
+ # password_file option) to control authenticated client access.
441
+ # Defaults to true.
442
+ #allow_anonymous true
443
+
444
+ # In addition to the clientid_prefixes, allow_anonymous and TLS
445
+ # authentication options, username based authentication is also
446
+ # possible. The default support is described in "Default
447
+ # authentication and topic access control" below. The auth_plugin
448
+ # allows another authentication method to be used.
449
+ # Specify the path to the loadable plugin and see the
450
+ # "Authentication and topic access plugin options" section below.
451
+ #auth_plugin
452
+
453
+ # -----------------------------------------------------------------
454
+ # Default authentication and topic access control
455
+ # -----------------------------------------------------------------
456
+
457
+ # Control access to the broker using a password file. This file can be
458
+ # generated using the mosquitto_passwd utility. If TLS support is not compiled
459
+ # into mosquitto (it is recommended that TLS support should be included) then
460
+ # plain text passwords are used, in which case the file should be a text file
461
+ # with lines in the format:
462
+ # username:password
463
+ # The password (and colon) may be omitted if desired, although this
464
+ # offers very little in the way of security.
465
+ #
466
+ # See the TLS client require_certificate and use_identity_as_username options
467
+ # for alternative authentication options.
468
+ #password_file
469
+
470
+ # Access may also be controlled using a pre-shared-key file. This requires
471
+ # TLS-PSK support and a listener configured to use it. The file should be text
472
+ # lines in the format:
473
+ # identity:key
474
+ # The key should be in hexadecimal format without a leading "0x".
475
+ #psk_file
476
+
477
+ # Control access to topics on the broker using an access control list
478
+ # file. If this parameter is defined then only the topics listed will
479
+ # have access.
480
+ # If the first character of a line of the ACL file is a # it is treated as a
481
+ # comment.
482
+ # Topic access is added with lines of the format:
483
+ #
484
+ # topic [read|write] <topic>
485
+ #
486
+ # The access type is controlled using "read" or "write". This parameter
487
+ # is optional - if not given then the access is read/write.
488
+ # <topic> can contain the + or # wildcards as in subscriptions.
489
+ #
490
+ # The first set of topics are applied to anonymous clients, assuming
491
+ # allow_anonymous is true. User specific topic ACLs are added after a
492
+ # user line as follows:
493
+ #
494
+ # user <username>
495
+ #
496
+ # The username referred to here is the same as in password_file. It is
497
+ # not the clientid.
498
+ #
499
+ #
500
+ # If is also possible to define ACLs based on pattern substitution within the
501
+ # topic. The patterns available for substition are:
502
+ #
503
+ # %c to match the client id of the client
504
+ # %u to match the username of the client
505
+ #
506
+ # The substitution pattern must be the only text for that level of hierarchy.
507
+ #
508
+ # The form is the same as for the topic keyword, but using pattern as the
509
+ # keyword.
510
+ # Pattern ACLs apply to all users even if the "user" keyword has previously
511
+ # been given.
512
+ #
513
+ # If using bridges with usernames and ACLs, connection messages can be allowed
514
+ # with the following pattern:
515
+ # pattern write $SYS/broker/connection/%c/state
516
+ #
517
+ # pattern [read|write] <topic>
518
+ #
519
+ # Example:
520
+ #
521
+ # pattern write sensor/%u/data
522
+ #
523
+ #acl_file
524
+
525
+ # -----------------------------------------------------------------
526
+ # Authentication and topic access plugin options
527
+ # -----------------------------------------------------------------
528
+
529
+ # If the auth_plugin option above is used, define options to pass to the
530
+ # plugin here as described by the plugin instructions. All options named
531
+ # using the format auth_opt_* will be passed to the plugin, for example:
532
+ #
533
+ # auth_opt_db_host
534
+ # auth_opt_db_port
535
+ # auth_opt_db_username
536
+ # auth_opt_db_password
537
+
538
+
539
+ # =================================================================
540
+ # Bridges
541
+ # =================================================================
542
+
543
+ # A bridge is a way of connecting multiple MQTT brokers together.
544
+ # Create a new bridge using the "connection" option as described below. Set
545
+ # options for the bridges using the remaining parameters. You must specify the
546
+ # address and at least one topic to subscribe to.
547
+ # Each connection must have a unique name.
548
+ # The address line may have multiple host address and ports specified. See
549
+ # below in the round_robin description for more details on bridge behaviour if
550
+ # multiple addresses are used.
551
+ # The direction that the topic will be shared can be chosen by
552
+ # specifying out, in or both, where the default value is out.
553
+ # The QoS level of the bridged communication can be specified with the next
554
+ # topic option. The default QoS level is 0, to change the QoS the topic
555
+ # direction must also be given.
556
+ # The local and remote prefix options allow a topic to be remapped when it is
557
+ # bridged to/from the remote broker. This provides the ability to place a topic
558
+ # tree in an appropriate location.
559
+ # For more details see the mosquitto.conf man page.
560
+ # Multiple topics can be specified per connection, but be careful
561
+ # not to create any loops.
562
+ # If you are using bridges with cleansession set to false (the default), then
563
+ # you may get unexpected behaviour from incoming topics if you change what
564
+ # topics you are subscribing to. This is because the remote broker keeps the
565
+ # subscription for the old topic. If you have this problem, connect your bridge
566
+ # with cleansession set to true, then reconnect with cleansession set to false
567
+ # as normal.
568
+ #connection <name>
569
+ #address <host>[:<port>] [<host>[:<port>]]
570
+ #topic <topic> [[[out | in | both] qos-level] local-prefix remote-prefix]
571
+
572
+ # If the bridge has more than one address given in the address/addresses
573
+ # configuration, the round_robin option defines the behaviour of the bridge on
574
+ # a failure of the bridge connection. If round_robin is false, the default
575
+ # value, then the first address is treated as the main bridge connection. If
576
+ # the connection fails, the other secondary addresses will be attempted in
577
+ # turn. Whilst connected to a secondary bridge, the bridge will periodically
578
+ # attempt to reconnect to the main bridge until successful.
579
+ # If round_robin is true, then all addresses are treated as equals. If a
580
+ # connection fails, the next address will be tried and if successful will
581
+ # remain connected until it fails
582
+ #round_robin false
583
+
584
+ # Set the client id for this bridge connection. If not defined,
585
+ # this defaults to 'name.hostname' where name is the connection
586
+ # name and hostname is the hostname of this computer.
587
+ #clientid
588
+
589
+ # Set the clean session variable for this bridge.
590
+ # When set to true, when the bridge disconnects for any reason, all
591
+ # messages and subscriptions will be cleaned up on the remote
592
+ # broker. Note that with cleansession set to true, there may be a
593
+ # significant amount of retained messages sent when the bridge
594
+ # reconnects after losing its connection.
595
+ # When set to false, the subscriptions and messages are kept on the
596
+ # remote broker, and delivered when the bridge reconnects.
597
+ #cleansession false
598
+
599
+ # If set to true, publish notification messages to the local and remote brokers
600
+ # giving information about the state of the bridge connection. Retained
601
+ # messages are published to the topic $SYS/broker/connection/<clientid>/state
602
+ # unless the notification_topic option is used.
603
+ # If the message is 1 then the connection is active, or 0 if the connection has
604
+ # failed.
605
+ #notifications true
606
+
607
+ # Choose the topic on which notification messages for this bridge are
608
+ # published. If not set, messages are published on the topic
609
+ # $SYS/broker/connection/<clientid>/state
610
+ #notification_topic
611
+
612
+ # Set the keepalive interval for this bridge connection, in
613
+ # seconds.
614
+ #keepalive_interval 60
615
+
616
+ # Set the start type of the bridge. This controls how the bridge starts and
617
+ # can be one of three types: automatic, lazy and once. Note that RSMB provides
618
+ # a fourth start type "manual" which isn't currently supported by mosquitto.
619
+ #
620
+ # "automatic" is the default start type and means that the bridge connection
621
+ # will be started automatically when the broker starts and also restarted
622
+ # after a short delay (30 seconds) if the connection fails.
623
+ #
624
+ # Bridges using the "lazy" start type will be started automatically when the
625
+ # number of queued messages exceeds the number set with the "threshold"
626
+ # parameter. It will be stopped automatically after the time set by the
627
+ # "idle_timeout" parameter. Use this start type if you wish the connection to
628
+ # only be active when it is needed.
629
+ #
630
+ # A bridge using the "once" start type will be started automatically when the
631
+ # broker starts but will not be restarted if the connection fails.
632
+ #start_type automatic
633
+
634
+ # Set the amount of time a bridge using the automatic start type will wait
635
+ # until attempting to reconnect. Defaults to 30 seconds.
636
+ #restart_timeout 30
637
+
638
+ # Set the amount of time a bridge using the lazy start type must be idle before
639
+ # it will be stopped. Defaults to 60 seconds.
640
+ #idle_timeout 60
641
+
642
+ # Set the number of messages that need to be queued for a bridge with lazy
643
+ # start type to be restarted. Defaults to 10 messages.
644
+ # Must be less than max_queued_messages.
645
+ #threshold 10
646
+
647
+ # If try_private is set to true, the bridge will attempt to indicate to the
648
+ # remote broker that it is a bridge not an ordinary client. If successful, this
649
+ # means that loop detection will be more effective and that retained messages
650
+ # will be propagated correctly. Not all brokers support this feature so it may
651
+ # be necessary to set try_private to false if your bridge does not connect
652
+ # properly.
653
+ #try_private true
654
+
655
+ # Set the username to use when connecting to an MQTT v3.1 broker
656
+ # that requires authentication.
657
+ #username
658
+
659
+ # Set the password to use when connecting to an MQTT v3.1 broker
660
+ # that requires authentication. This option is only used if
661
+ # username is also set.
662
+ #password
663
+
664
+ # -----------------------------------------------------------------
665
+ # Certificate based SSL/TLS support
666
+ # -----------------------------------------------------------------
667
+ # Either bridge_cafile or bridge_capath must be defined to enable TLS support
668
+ # for this bridge.
669
+ # bridge_cafile defines the path to a file containing the
670
+ # Certificate Authority certificates that have signed the remote broker
671
+ # certificate.
672
+ # bridge_capath defines a directory that will be searched for files containing
673
+ # the CA certificates. For bridge_capath to work correctly, the certificate
674
+ # files must have ".crt" as the file ending and you must run "c_rehash <path to
675
+ # capath>" each time you add/remove a certificate.
676
+ #bridge_cafile
677
+ #bridge_capath
678
+
679
+ # Path to the PEM encoded client certificate, if required by the remote broker.
680
+ #bridge_certfile
681
+
682
+ # Path to the PEM encoded client private key, if required by the remote broker.
683
+ #bridge_keyfile
684
+
685
+ # When using certificate based encryption, bridge_insecure disables
686
+ # verification of the server hostname in the server certificate. This can be
687
+ # useful when testing initial server configurations, but makes it possible for
688
+ # a malicious third party to impersonate your server through DNS spoofing, for
689
+ # example. Use this option in testing only. If you need to resort to using this
690
+ # option in a production environment, your setup is at fault and there is no
691
+ # point using encryption.
692
+ #bridge_insecure false
693
+
694
+ # -----------------------------------------------------------------
695
+ # PSK based SSL/TLS support
696
+ # -----------------------------------------------------------------
697
+ # Pre-shared-key encryption provides an alternative to certificate based
698
+ # encryption. A bridge can be configured to use PSK with the bridge_identity
699
+ # and bridge_psk options. These are the client PSK identity, and pre-shared-key
700
+ # in hexadecimal format with no "0x". Only one of certificate and PSK based
701
+ # encryption can be used on one
702
+ # bridge at once.
703
+ #bridge_identity
704
+ #bridge_psk
705
+
706
+
707
+ # =================================================================
708
+ # External config files
709
+ # =================================================================
710
+
711
+ # External configuration files may be included by using the
712
+ # include_dir option. This defines a directory that will be searched
713
+ # for config files. All files that end in '.conf' will be loaded as
714
+ # a configuration file. It is best to have this as the last option
715
+ # in the main file. This option will only be processed from the main
716
+ # configuration file. The directory specified must not contain the
717
+ # main configuration file.
718
+ #include_dir
719
+
720
+ # =================================================================
721
+ # Unsupported rsmb options - for the future
722
+ # =================================================================
723
+
724
+ #addresses
725
+ #round_robin
726
+
727
+ # =================================================================
728
+ # rsmb options - unlikely to ever be supported
729
+ # =================================================================
730
+
731
+ #ffdc_output
732
+ #max_log_entries
733
+ #trace_level
734
+ #trace_output