ltm rule command MQTT replace
iRule(1) BIG-IP TMSH Manual iRule(1)
MQTT::replace
Replace MQTT message
SYNOPSIS
MQTT::replace ( (('type' 'CONNECT') ('client_id' NAME)
('keep_alive' KEEP_ALIVE)?
('clean_session' BOOLEAN)?
('protocol_name' NAME)?
('protocol_version' VERSION)?
('username' NAME)?
('password' PASSWORD)?
('will_topic' TOPIC)?
('will_message' CONTENT)?
('will_qos' ('0' | '1' | '2'))?
('will_retain' BOOLEAN)?) |
(('type' 'CONNACK') ('return_code' RETURN_CODE)
('session_present' BOOLEAN)?) |
(('type' 'PUBLISH') ('topic' TOPIC) ('payload' CONTENT)
(('qos' '0') | (('qos' ('1' | '2')) ('packet_id' PACKETID)))?
('dup' BOOLEAN)?
('retain' BOOLEAN)?) |
(('type' ('PUBACK' | 'PUBREC' | 'PUBREL' | 'PUBCOMP')) ('packet_id' PACKETID)) |
(('type' 'SUBSCRIBE') ('packet_id' PACKETID)
('topic_list' (TOPIC ('0' | '1' | '2'))+)?) |
(('type' 'SUBACK') ('packet_id' PACKETID) ('return_code_list' (RETURN_CODE)+)) |
(('type' 'UNSUBSCRIBE') ('packet_id' PACKETID) ('topic_list' (TOPIC ('0' | '1' |
'2'))+)) |
(('type' 'UNSUBACK') ('packet_id' PACKETID)) |
(('type' ('PINGREQ' | 'PINGRESP' | 'DISCONNECT')))
)
DESCRIPTION
This command can be used to replace current MQTT message. This command is valid for all MQTT message types:
CONNECT, CONNACK,
PUBLISH, PUBACK, PUBREC, PUBREL, PUBCOMP,
SUBSCRIBE, SUBACK,
UNSUBSCRIBE, UNSUBACK,
PINGREQ, PINGRESP,
DISCONNECT
Syntax
MQTT::replace type CONNECT client_id
[keep_alive ] [clean_session (0 | 1)]
[protocol_name ] [protocol_version ]
[username ] [password ]
[will_topic ] [will_message ]
[will_qos (0 | 1 |2)] [will_retain (0 | 1)]
* The client_id is required parameter.
keep_alive must be smaller than 65536.
Default values for optional parameters are:
keep_alive -: 60 seconds.
clean_session -: 1
protocol_name -: MQTT
protocol_version -: 4
username -: ""
password -: ""
will_topic -: ""
will_message -: ""
will_qos -: 0
will_retain -: 0
MQTT::replace type CONNACK return_code
[ session_present ]
* The values must be set to one of the following:.
0 - Connection Accepted.
1 - Connection Refused, unacceptable protocol version.
2 - Connection Refused, identifier rejected.
3 - Connection Refused, Server unavailable.
4 - Connection Refused, bad username or password.
5 - Connection Refused, not authorized.
The can be set to 0 or 1. The default value is 0.
MQTT::replace type PUBLISH topic payload
[{qos 0} | {qos (1 | 2) packet_id } ]
[dup (0 | 1)]
[retain (0 | 1)]
* For PUBLISH, the topic and payload are required parameters. If qos is 1 or 2, then packet_id must also be specified.
must be smaller than 65536.
Default values for optional parameters are:
qos -: 0
dup -: 0
retain -: 0
MQTT::replace type PUBACK packet_id MQTT::replace type PUBREC packet_id
MQTT::replace type PUBREL packet_id MQTT::replace type PUBCOMP
packet_id
* For PUBACK, PUBREC, PUBREL, and PUBCOMP, packet_id is a required parameter. No other parameter should be
specified.
must be smaller than 65536.
MQTT::replace type SUBSCRIBE packet_id topic_list { }+
* For SUBSCRIBE, packet_id and topic_list are required parameters. No other parameter should be specified.
must be smaller than 65536. can only be 0,1, or 2.
MQTT::replace type SUBACK packet_id return_code_list {}+
* For SUBACK, packet_id and return_code_list are required parameters. No other parameter should be
specified.
must be smaller than 65536.
For return_code_list, each number in the list must be smaller than 256. Valid values are:
0 : Success - Maximum QoS 0.
1 : Success - Maximum QoS 1.
2 : Success - Maximum QoS 2.
128 : Failure
Other : Reserved for future use.
MQTT::replace type UNSUBSCRIBE packet_id topic_list { }+
* For UNSUBSCRIBE, packet_id and topic_list are required parameters. No other parameter should be
specified.
Please note that values will be ignored. It is required to make format of topic_list same between
SUBSCRIBE and UNSUBSCRIBE.
UNSUBSCRIBE does not need the qos.
MQTT::replace type UNSUBACK packet_id
* For UNSUBACK, packet_id is required parameter.
MQTT::replace type PINGREQ
* For PINGREQ should be used with no parameter.
MQTT::replace type PINGRESP
* For PINGRESP should be used with no parameter.
MQTT::replace type DISCONNECT
* For DISCONNECT should be used with no parameter.
RETURN VALUE
None.
VALID DURING
MQTT_CLIENT_INGRESS MQTT_SERVER_INGRESS MQTT_CLIENT_DATA MQTT_SERVER_DATA
EXAMPLES
#Example: Split SUBSCRIBE with multiple topics into individual SUBSCRIBE messages
when MQTT_CLIENT_INGRESS {
set type [MQTT::type]
switch $type {
"SUBSCRIBE" {
set count [MQTT::topic count]
if { $count > 1 } {
set topiclist [MQTT::topic list]
set qoslist [list]
foreach topic $topiclist {
lappend qoslist [MQTT::topic qos $topic]
}
set i 0
foreach topic $topiclist {
if { $i == 0 } {
MQTT::replace type SUBSCRIBE packet_id [MQTT::packet_id] topic_list $topic [lindex $qoslist $i]
} else {
MQTT::insert after type SUBSCRIBE packet_id [expr { 1000 + $i}] topic_list $topic [lindex $qoslist $i]
}
set i [expr { $i + 1 }]
}
}
}
}
}
when MQTT_SERVER_INGRESS {
set type [MQTT::type]
switch $type {
"SUBACK" {
if {[MQTT::packet_id] > 1000} {
MQTT::drop
}
}
}
}
HINTS
SEE ALSO
CHANGE LOG
@BIGIP-13.0.0 --First introduced the command.
BIG-IP 2020-06-23 iRule(1)