Hi DonAlfredo, and thank you! Yes, that is the general way to do it. There are also 2 bits that need to be set in the FixedHeader, and I will try this tonight. Oddly, all versions of the Delphi-forked MQTT code have this in the ReadThread connect code,
// Build CONNECT message
FH := FixedHeader(MQTT.CONNECT, 0, 0, 0);
VH := VariableHeaderConnect(40);
SetLength(Payload, 0);
AppendArray(Payload, StrToBytes(FClientID, True));
AppendArray(Payload, StrToBytes('lwt', True));
AppendArray(Payload, StrToBytes(FClientID + ' died', True));
RL := RemainingLength(Length(VH) + Length(Payload));
Data := BuildCommand(FH, RL, VH, Payload);
(BOLD sections highlighted by me) It looks like 'lwt' and FClientID+' died' are hard-coded Will topic/message information to be sent if the connection dies. Does everyone use this same topic/message, or is this a vestigial bit of code?