Skip to content

Commit

Permalink
fix(web):fix topic-alias-maximum error in connect
Browse files Browse the repository at this point in the history
  • Loading branch information
ni00 committed Sep 28, 2023
1 parent 4c0e2cf commit 0b5497a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion web/src/utils/mqttUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,13 @@ const getUrl = (record: ConnectionModel): string => {
export const createClient = (record: ConnectionModel): { curConnectClient: MqttClient; connectUrl: string } => {
const options: IClientOptions = getClientOptions(record)
const url = getUrl(record)
const curConnectClient: MqttClient = mqtt.connect(url, options)
// Map options.properties.topicAliasMaximum to options.topicAliasMaximum, as that is where MQTT.js looks for it.
// TODO: remove after bug fixed in MQTT.js v5.
const optionsTempWorkAround = Object.assign(
{ topicAliasMaximum: options.properties ? options.properties.topicAliasMaximum : undefined },
options,
)
const curConnectClient: MqttClient = mqtt.connect(url, optionsTempWorkAround)

return { curConnectClient, connectUrl: url }
}
Expand Down

0 comments on commit 0b5497a

Please sign in to comment.