Coder Social home page Coder Social logo

cordova-plugin-fastrde-mqtt's Introduction

not maintained anymore

cordova-plugin-fastrde-mqtt

mqtt.init(options)

Initialize the mqtt-client with the given options.

    host - borker to connect to [required]
    port - port to connect to [default 1883]
    qos - Quality of Service level[default 0]
    clientId - Unique Identifier for the Client [default cordova_mqtt_<random>]
    username - username for broker authentication [default none] 
    password - password for broker authentication [default none]
    ssl - should ssl be used [default false]
    keepAlive - keepAlive sending interval in seconds [default 10]
    timeout - session timeouts after <timeout> seconds [default 30]
    cleanSession - clean Session at disconnect [default true]
    protocol - mqtt protocol level [default 4] 
    offlineCaching - should mesages be cached in sqlite before sending [default true]

mqtt.connect()

connect to the broker with the initial given options.

mqtt.disconnect()

disconnect from the broker.

mqtt.publish(message)

Send a Message.

    topic - topic where the message is send to
    message - payload of the message
    qos - Quality of Service level
    retain - should the message retain in the channel

mqtt.subscribe(options)

Subscribes to the topic with the given options

    topic - topic to subscribe
    qos - Quality of Service of the Subscription

mqtt.unsubscribe(options)

Subscribes to the topic with the given options

    topic - topic to unsubscribe

mqtt.on(event, success, error)

set callback functions for the given event.

    event - could be 
      "init":

      "connect": 
        success(status)
        error(errorMessage)
      "disconnect": 
        success(status)
        error(errorMessage)
      "publish": 
        success(message)
        error(errorMessage)
      "subscribe": 
        success(subscribtion)
        error(errorMessage)
      "unsubscribe": 
        success(topic)
        error(errorMessage)
     "message": 
        success(message)
    
    success - callback that get called on success of the event
    error - callback that get called on error of the event

mqtt.will(message)

    topic - topic where the last will is send to on disconnect
    message - payload of the message
    qos - Quality of Service level
    retain - should the message retain in the channel

cordova-plugin-fastrde-mqtt's People

Contributors

fastrde avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cordova-plugin-fastrde-mqtt's Issues

Got exception in iOS by calling 'mqtt.connect'

I tried to use this plugin in my cordova project, after added and build to device, i tried to call mqtt init, it returns undefined, not sure why, please help to take a look.
My dev env is:

Node version: v6.9.1
Cordova version: 6.3.1
iOS platform:
Xcode 8.1
Build version 8B62

My test code is:

mqtt.init({
   host: '192.168.0.3',
});

mqtt.connect();

Exceptions Detail

2016-11-27 15:47:41.487320 bolang-app-new[6925:2252293] mqtt init
2016-11-27 15:47:41.487503 bolang-app-new[6925:2252293] mqtt connect
2016-11-27 15:47:41.489338 bolang-app-new[6925:2252293] MQTT Initialized
2016-11-27 15:47:41.491068 bolang-app-new[6925:2252332] connect 192.168.139.2:1883
2016-11-27 15:47:41.491159 bolang-app-new[6925:2252332] ==================
2016-11-27 15:47:41.491238 bolang-app-new[6925:2252332] clientId: cordova_mqtt_b42826ee
2016-11-27 15:47:41.491356 bolang-app-new[6925:2252332] userName: <null>
2016-11-27 15:47:41.491441 bolang-app-new[6925:2252332] password: <null>
2016-11-27 15:47:41.491494 bolang-app-new[6925:2252332] keepAlive: 10
2016-11-27 15:47:41.491534 bolang-app-new[6925:2252332] cleanSession: 1
2016-11-27 15:47:41.491574 bolang-app-new[6925:2252332] protocol: 4
2016-11-27 15:47:41.491612 bolang-app-new[6925:2252332] ssl: 0
2016-11-27 15:47:41.743437 bolang-app-new[6925:2252293] -[NSNull dataUsingEncoding:]: unrecognized selector sent to instance 0x1a9edaef8
2016-11-27 15:47:41.744809 bolang-app-new[6925:2252293] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull dataUsingEncoding:]: unrecognized selector sent to instance 0x1a9edaef8'
*** First throw call stack:
(0x184e1a1c0 0x18385455c 0x184e21278 0x184e1e278 0x184d1859c 0x1001d9664 0x1001d82a4 0x1001e4dcc 0x1001da2c4 0x184d64258 0x184d6f0c0 0x184d63d7c 0x185521a74 0x18551d758 0x184dcd210 0x184dc8278 0x184dc7bc0 0x184dc57c0 0x184cf4048 0x18677a198 0x18ace02fc 0x18acdb034 0x100017108 0x183cd85b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

userName and password on comment on iOS

Hi, on src/ion/*.m the lines for userName and password are on comment.
Indeed, the label "userName" of the options has to be changed to "username" twice on the same line.
With these changes, all is working fine

offlineCaching: false - getting error on publish

With offlineCaching: false configuration I unable to publish message. Getting error:
direct publishing failed: at file:///android_asset/www/plugins/cordova-plugin-fastrde-mqtt/www/mqtt.js:215

Example code:

mqtt.init({
                        offlineCaching: false,
                        host: cfg.host,
                        port: cfg.port,
                        username: cfg.username,
                        password: cfg.password,
                        ssl: cfg.ssl
                    });

                    mqtt.on('connect', function() {
                        mqtt.subscribe({
                            topic: '/aircon/state', qos: 0
                        });
                        mqtt.publish({
                            topic: '/aircon', message: 'state'
                        });
                    });

                    mqtt.connect();

How stable is this plugin?

How stable is this plugin?
How does it compare to other similar plugins? For example cordova-plugin-mqtt?
This is the first plugin that seems to support SSL. Are there known bugs?
Is it safe to use in professional environment?

need help to fix MQTT ios cordova plugin [CONNACK problem]

Hi guys!

Firstly, many thanks for your submitted open source code at https://github.com/fastrde. We appreciate your work! Thanks!

We tried to use your code from Github: https://github.com/fastrde/cordova-plugin-fastrde-mqtt and got some troubles.... We found out that the fix from giriiton solved a part of problems (decencies) > https://github.com/giriiton/cordova-plugin-fastrde-mqtt/blob/master/plugin.xml#L10 but we have a problem connected with "CONNACK" - it seems that the problem began from your source code

"SyntaxError: Unexpected identifier 'CONNACK'. Expected ')' to end an argument list."

Guys, could you please help us! And double check your code (Object C binary) and fix that issue? Or maybe you can show the problem place and we'll fix that.

Had no chance to play with Object C code.... :)

How to Import?

I'm struggling to understand how to import your plugin. (I'm still learning how to use Cordova...) For now, I'm doing this:

import mqtt from '../../../plugins/cordova-plugin-fastrde-mqtt/www/mqtt.js';

This allows me to build, but I get an error when I connect:

ERROR ReferenceError: cordova is not defined
at Object._connect (mqtt.js:150)
at Object.connect (mqtt.js:137)

I'm thinking I'm doing something wrong with the import or how I'm linking to the plugin. I installed it from the command line. I did have to use --force to get past a database dependency. (I have a later version of the database code.)

Many requests of connections

In the broker of mqtt I can see many messages:

[WARNING] MQTT disconnecting duplicate client id "q-buzon-col_messages_3eee7f81ac409aa0" ("xxx:11443 -> xxx:1883")

Only for devices Android, It's like it falls into a loop of connection attempts.

The plugin has a reconnect logic?
Has anyone happened to this?

thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.