arcoirislabs / cordova-plugin-mqtt

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

Failed to connect #11

Closed ionciubotaru closed 8 years ago

ionciubotaru commented 8 years ago

Please help me with the following: I use https://build.phonegap.com to build your sampleapp. I tried to connect to tcp://test.mosquitto.org port 1883, but I received --> You got `disconnected and never succed to connect.

Config.xml is:

<?xml version="1.0" encoding="UTF-8"?>
    <widget xmlns  = "http://www.w3.org/ns/widgets"
        xmlns:gap     = "http://phonegap.com/ns/1.0"
        id                   = "com.phonegap.example"
        versionCode = "10" 
        version     = "1.0.0" >
    <name>Test</name>
    <platform name="android" />
    <description>Test</description>
    <preference name="android-build-tool" value="gradle" /> 
    <gap:plugin name="cordova-plugin-mqtt" spec="0.2.7" source="npm" />

    <preference name="phonegap-version" value="cli-5.2.0" />
    <preference name="orientation"      value="default" />
    <preference name="target-device"    value="universal" />
    <preference name="fullscreen"       value="false" />
    <preference name="webviewbounce"    value="false" />
</widget>
arcoirislabs commented 8 years ago

Sure we will give a looks at the issue.

Open source team Arcoiris Labs

On 14-May-2016, at 8:25 PM, Ion notifications@github.com wrote:

Please help me with the following: I use https://build.phonegap.com to build your sampleapp. I tried to connect to tcp://test.mosquitto.org port 1883, but I received --> You got `disconnected and never succed to connect.

Config.xml is:

<?xml version="1.0" encoding="UTF-8"?> <widget xmlns = "http://www.w3.org/ns/widgets" xmlns:gap = "http://phonegap.com/ns/1.0" id = "com.phonegap.example" versionCode = "10" version = "1.0.0" >

Test
<platform name="android" />
<description>Test</description>
<preference name="android-build-tool" value="gradle" /> 
<gap:plugin name="cordova-plugin-mqtt" spec="0.2.7" source="npm" />
<preference name="phonegap-version" value="cli-5.2.0" />
<preference name="orientation"      value="default" />
<preference name="target-device"    value="universal" />
<preference name="fullscreen"       value="false" />
<preference name="webviewbounce"    value="false" />

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub

arcoirislabs commented 8 years ago

@ionciubotaru We looked into the issue and we found no issues with the connection part. Our config.xml was this

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.phonegap.helloworld" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
    <name>Hello World</name>
    <description>
        Hello World sample application that responds to the deviceready event.
    </description>
    <author email="support@phonegap.com" href="http://phonegap.com">
        PhoneGap Team
    </author>
    <content src="index.html" />
    <preference name="DisallowOverscroll" value="true" />
    <preference name="android-minSdkVersion" value="14" />
    <preference name="android-build-tool" value="gradle" />
    <gap:plugin name="cordova-plugin-mqtt" spec="0.2.7" source="npm" />
    <preference name="phonegap-version" value="cli-5.2.0" />
    <preference name="orientation"      value="default" />
    <preference name="target-device"    value="universal" />
    <preference name="fullscreen"       value="false" />
    <preference name="webviewbounce"    value="false" />
    <icon src="icon.png" />
    <platform name="android">
        <icon density="ldpi" src="www/res/icon/android/drawable-ldpi-icon.png" />
        <icon density="mdpi" src="www/res/icon/android/drawable-mdpi-icon.png" />
        <icon density="hdpi" src="www/res/icon/android/drawable-hdpi-icon.png" />
        <icon density="xhdpi" src="www/res/icon/android/drawable-xhdpi-icon.png" />
        <icon density="xxhdpi" src="www/res/icon/android/drawable-xxhdpi-icon.png" />
        <icon density="xxxhdpi" src="www/res/icon/android/drawable-xxxhdpi-icon.png" />
        <splash density="land-ldpi" src="www/res/screen/android/drawable-land-ldpi-screen.png" />
        <splash density="land-mdpi" src="www/res/screen/android/drawable-land-mdpi-screen.png" />
        <splash density="land-hdpi" src="www/res/screen/android/drawable-land-hdpi-screen.png" />
        <splash density="land-xhdpi" src="www/res/screen/android/drawable-land-xhdpi-screen.png" />
        <splash density="land-xxhdpi" src="www/res/screen/android/drawable-land-xxhdpi-screen.png" />
        <splash density="land-xxxhdpi" src="www/res/screen/android/drawable-land-xxxhdpi-screen.png" />
        <splash density="port-ldpi" src="www/res/screen/android/drawable-port-ldpi-screen.png" />
        <splash density="port-mdpi" src="www/res/screen/android/drawable-port-mdpi-screen.png" />
        <splash density="port-hdpi" src="www/res/screen/android/drawable-port-hdpi-screen.png" />
        <splash density="port-xhdpi" src="www/res/screen/android/drawable-port-xhdpi-screen.png" />
        <splash density="port-xxhdpi" src="www/res/screen/android/drawable-port-xxhdpi-screen.png" />
        <splash density="port-xxxhdpi" src="www/res/screen/android/drawable-port-xxxhdpi-screen.png" />
    </platform>

    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
</widget>

And our connection configuration was this

cordova.plugins.CordovaMqTTPlugin.connect({
    url:"tcp://test.mosquitto.org", //a public broker used for testing purposes only. Try using a self hosted broker for production.
    port:1883, 
    clientId:"arcoirislabs",
    connectionTimeout:3000,
    willTopicConfig:{
        qos:0,
        retain:true,
        topic:"<will topic>",
        payload:"<will topic message>"
    },
    keepAlive:60,
    success:function(s){
        console.log("connect success");
    },
    error:function(e){
        console.log("connect error");
    },
    onConnectionLost:function (){
        console.log("disconnect");
    }
})

And it worked perfectly fine. If you need we can provide you the APK.

arcoirislabs commented 8 years ago

@ionciubotaru We tried to recreate the issue and it seems that either you used credentials for a public broker or the client ID's length exceed the 24 chars length limit. If you still got any issues, do let us know. We will be glad to help you.

Open Source Team Arcoiris Labs