Emitted after client is connected to the broker.
client.on("connect", () => {
console.log("Client Connected !!");
});
Emitted after broker is ready to receive packets
client.on("ready", () => {
console.log("Client Ready !!");
});
Emitted after connection closed.
hadError
- Type:
boolean
- Description: If connection closed because of an error or not.
client.on("close", (hadError) => {
console.log("Client Connection Closed !!");
});
Emitted after connection ends.
client.on("end", (hadError) => {
console.log("Client Connection Ended !!");
});
Emitted after an error occured.
error
- Type:
Error
- Description: Error argument in tcp socket.
client.on("close", (hadError) => {
console.log("Client Connection Closed !!");
});
Emitted after connection timedout.
client.on("timeout", (hadError) => {
console.log("Connection Timedout !!");
});
Emitted after broker accepts client connection.
returnCode
- Type:
any
- Description: Return code from the broker.
message
- Type:
string
- Description: Message from the broker.
client.on("connectionAccepted", ({ returnCode, message }) => {
console.log("Client Connection Accepted !!");
});
Emitted after if broker refuses client connection
returnCode
- Type:
any
- Description: Return code from the broker.
message
- Type:
string
- Description: Message from the broker.
client.on("connectionRefused", ({ returnCode, message }) => {
console.log("Client Connection Refused !!");
});
Emitted after ping response received by client
response
- Type:
string
- Description: Default pingresp message
client.on("pingresp", (response) => {
console.log("Server pinged back !!");
});
Emitted after subscribe acknowledgement packet received by client
packetID
- Type:
number[]
- Description: Packet identifier
returnCodes
-
Type:
object
-
Description: Suback information
-
Properties:
type
: stringmessage
: stringreturnCode
: string
client.on("suback", ({ packetID, returnCodes }) => {
console.log("Client SuBack Response", returnCodes, packetID);
});
Emitted after unsubscribe acknowledgement packet received by client
client.on("unsuback", ({ packetID, returnCodes }) => {});