Currently, when building cordova-plugin-mqtt with 'browser' target, two significant problems are observed:
Constructing new Paho.MQTT.Message in 'connect' method wants to have args.payloadString as a will-payload. Meanwhile, there is no such field in connection options, and that causes 'invalid argument undefined' error on all connection attempts. The correct field is 'args.willTopicConfig.payload'.
'connect' method wants to have 'wsPort' field in connection options. This is absolutely logical because browser-target implementation uses PahoMQTT, that can connect to MQTT broker only via WebSockets protocol. Meanwhile, there are no absolutely no mentions about it in README documentation and omitting this parameter will cause runtime errors too. I think the correct way is to check is 'wsPort' param is present, and if not, use 'port' parameter instead.
Currently, when building cordova-plugin-mqtt with 'browser' target, two significant problems are observed:
Constructing new Paho.MQTT.Message in 'connect' method wants to have args.payloadString as a will-payload. Meanwhile, there is no such field in connection options, and that causes 'invalid argument undefined' error on all connection attempts. The correct field is 'args.willTopicConfig.payload'.
'connect' method wants to have 'wsPort' field in connection options. This is absolutely logical because browser-target implementation uses PahoMQTT, that can connect to MQTT broker only via WebSockets protocol. Meanwhile, there are no absolutely no mentions about it in README documentation and omitting this parameter will cause runtime errors too. I think the correct way is to check is 'wsPort' param is present, and if not, use 'port' parameter instead.