pub struct Conf { /* private fields */ }
Expand description
Specify server behavior.
Many methods take a Vec
of values, where the Nth mod len()
value is used for the Nth
connection. For example, .max_pkt(vec![None,Some(3)])
applies the limit to every second
connection.
Implementations§
Source§impl Conf
impl Conf
Sourcepub fn ports(self, ports: RangeInclusive<u16>) -> Self
pub fn ports(self, ports: RangeInclusive<u16>) -> Self
Range of ports to try to listen on, stopping at the first successful one) (defaults to
1883..=2000
)
Sourcepub fn dump_files(self, vs: Vec<impl Into<String>>) -> Self
pub fn dump_files(self, vs: Vec<impl Into<String>>) -> Self
Dump packets to files.
The filename can contain a {c}
placeholder that will be replaced by the connection
number. The dump format is json-serialized DumpMeta
struct.
pub fn dump_prefix(self, s: impl Into<String>) -> Self
Sourcepub fn dump_decode(self, s: impl Into<Option<String>>) -> Self
pub fn dump_decode(self, s: impl Into<Option<String>>) -> Self
Decode command for publish payload.
The argument should be a command that reads raw payload from stdin, and writes the corresponding utf8/json to stdout. If decoding fails, it should output diagnostics to stderr and exit with a non-zero value.
Sourcepub fn ack_timeouts(
self,
mqtt3: impl Into<OptMsDuration>,
mqtt5: impl Into<OptMsDuration>,
) -> Self
pub fn ack_timeouts( self, mqtt3: impl Into<OptMsDuration>, mqtt5: impl Into<OptMsDuration>, ) -> Self
Resend packet during connection if ack takes longer than this (defaults to 5s).
This only concerns resending during a live connection: resending at connection start (if session was restored) always happens immediately.
The second value is for MQTT5 clients. MQTT5 forbids resending during connection, only set an MQTT5 value for testing purposes. MQTT3 doesn’t specify a behaviour, but many client/servers do resend non-acked packets during connection.
Sourcepub fn ack_delay(self, d: impl Into<OptMsDuration>) -> Self
pub fn ack_delay(self, d: impl Into<OptMsDuration>) -> Self
Delay before sending publish and subscribe acks.
Sourcepub fn strict(self, strict: bool) -> Self
pub fn strict(self, strict: bool) -> Self
Be stricter about optional MQTT behaviours.
- MQTT-3.1.3-5: Reject client_ids longer than 23 chars or not matching [0-9a-zA-Z].
- MQTT-3.1.3-6: Reject empty client_ids.
Sourcepub fn idprefix(self, s: impl Into<String>) -> Self
pub fn idprefix(self, s: impl Into<String>) -> Self
Reject clients whose client_id does not start with this prefix.
Sourcepub fn userpass(self, s: impl Into<Option<String>>) -> Self
pub fn userpass(self, s: impl Into<Option<String>>) -> Self
Reject clients who didn’t suppliy this username:password
Note that MQTT allows passwords to be binary but we only accept UTF-8.
Sourcepub fn max_connect(self, c: impl Into<Option<usize>>) -> Self
pub fn max_connect(self, c: impl Into<Option<usize>>) -> Self
Only accept up to N connections, and stop the server afterwards.
Sourcepub fn max_pkt(self, vou: Vec<impl Into<Option<usize>>>) -> Self
pub fn max_pkt(self, vou: Vec<impl Into<Option<usize>>>) -> Self
Disconnect the Nth client after receiving that many packets.
This just closes the TCP stream, without sending an mqtt disconnect packet.
Sourcepub fn max_pkt_delay(self, d: impl Into<OptMsDuration>) -> Self
pub fn max_pkt_delay(self, d: impl Into<OptMsDuration>) -> Self
Delay before max-pkt disconnection.
Useful if you want to receive the server response before disconnection.
Sourcepub fn max_time(self, vod: Vec<impl Into<OptMsDuration>>) -> Self
pub fn max_time(self, vod: Vec<impl Into<OptMsDuration>>) -> Self
Disconnect the Nth client after a certain time.
This just closes the TCP stream, without sending an mqtt disconnect packet.
Sourcepub fn sess_expire(self, vod: Vec<impl Into<OptMsDuration>>) -> Self
pub fn sess_expire(self, vod: Vec<impl Into<OptMsDuration>>) -> Self
How long is the Nth session retained after disconnection.
If None, use client-specified behaviour (clean_session in MQTT3, session expiry in MQTT5).