'Mqtt Android PahoClient Connection Issue

Hi I am using Android paho library for getting connect with an mqtt server.

My app level Gradle side Code :

implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.0'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'

Project Level

allprojects {

    repositories {
        jcenter()
        maven {
            url "https://repo.eclipse.org/content/repositories/paho-snapshots/"
        }
        maven { url "https://jitpack.io" }
        maven {
            url "https://maven.google.com"
        }
    }
}

In Manifest File

<service android:name="org.eclipse.paho.android.service.MqttService" />

permisiions

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

My issue is I am able to connect, publish data and subscribe to a topic when my server url is tcp://:1883

When I changed my url to mqtts://:8883 its failed to get connect

So what is the difference in the schemes tcp:// and mqtts:// or mqtt:// Why I am not able to connect if scheme starts with mqtt?

Please help!!!



Solution 1:[1]

tcp://hostname:1883 and mqtt://hostname:1883 are exactly the same.

mqtts://hostname:8883 is MQTT over TLS and will require that the broker has been correctly configured to support a TLS connection on port 8883.

Without details of the error when it fails to connect we can say nothing more.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 hardillb