arcoirislabs / cordova-plugin-mqtt

MqTT Cordova Plugin for Apache Cordova (> v3.0)
MIT License
86 stars 49 forks source link

Fix issues in 'browser' target #42

Closed uprtdev closed 5 years ago

uprtdev commented 5 years ago

Currently, when building cordova-plugin-mqtt with 'browser' target, two significant problems are observed:

  1. 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'.

  2. '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.