0

I'm using Paho's MQTT client on my android application as service. When I try it on API 26 and above it is working without problem but subscribe is not working under that version.

mqttClient.subscribe(JOIN_TOPIC, 0).setActionCallback(new IMqttActionListener() {
   @Override
   public void onSuccess(IMqttToken asyncActionToken) {
      Log.d("Client Service", "Subscribe Success");
   }

   @Override
   public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
      Log.d("Client Service", "Subscribe Failed");
   }
});

I'm using genymotion to test and SDK debugging tool. API 26 enters to onSuccess method but API 25 doesn't. Publish method don't has any problem on both client.

mqttClient = new MqttAndroidClient(getApplicationContext(), serverUri, nickname);
MqttConnectOptions options = new MqttConnectOptions();
options.setCleanSession(true);
mqttToken = mqttClient.connect(options);

There is no problem with connection. It is connected with no problem. I just want to know why subscribe has that problem on API versions under 26.

Hasan Alp Zengin
  • 99
  • 1
  • 1
  • 9

1 Answers1

0

Ok I found the problem. I was using moquette broker and broker has a problem under java version 8 and API level 25 was using java 6 somehow. There is no problem with paho's mqtt client. Thanks to everyone

Hasan Alp Zengin
  • 99
  • 1
  • 1
  • 9