0

I am trying to connect mqtt with the PAHO Mqtt android library. But it doesn't work for me. I think my server uri is not valid but I'm not sure.

              val clientId = MqttAsyncClient.generateClientId();
              val url = "wss://xxxxxxx.iot.us-east-1.amazonaws.com/mqtt?...."
              client = MqttAndroidClient(this,url, clientId)
                val token = client.connect()
                token.actionCallback = object : IMqttActionListener {
                    override fun onSuccess(asyncActionToken: IMqttToken) {
                        // We are connected
                        Log.i(TAG,"onSuccess")
                    }
                    override fun onFailure(asyncActionToken: IMqttToken, exception: Throwable) {
                        exception.printStackTrace()
                        Log.i(TAG,"onFailure")
                    }
            }

I see MqttException(0) in logcat. I looked into MqttException class decleration for understanding exception reason. I saw :

public class MqttException extends Exception {
    public static final short REASON_CODE_CLIENT_EXCEPTION              = 0x00;
}

Shorty, I have no idea why it is not connect to mqtt.

yusufonderd
  • 3,237
  • 4
  • 21
  • 34

0 Answers0