__Android API Version Bug Seen on:Checked on 22 and 24
Android Version Bug Seen on:Checked on 5.1 and 7.0
Description of Bug:
I hosted Mosquitto MQTT broker on Digital Ocean Cloud. Now, I am trying to connect it to the android studio. But it is not connecting to the MQTT broker.I tried with the following code.
public class MainActivity extends AppCompatActivity {
public MqttAndroidClient CLIENT;
public MqttConnectOptions MQTT_CONNECTION_OPTIONS;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String clientId = MqttClient.generateClientId();
MqttAndroidClient client =
new MqttAndroidClient(this.getApplicationContext(), "tcp://instrux.live:1883",
clientId);
try {
IMqttToken token = client.connect();
token.setActionCallback(new IMqttActionListener() {
@Override
public void onSuccess(IMqttToken asyncActionToken) {
// We are connected
Log.d("mqtt", "connected, token:" + asyncActionToken.toString());
}
@Override
public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
// Something went wrong e.g. connection timeout or firewall problems
Log.d("mqtt", "not connected" + asyncActionToken.toString());
}
});
} catch (MqttException e) {
e.printStackTrace();
}
}
}
Console Log output (if available):
Unregister alarmreceiver to MqttServicepaho6872628288140
2020-06-18 12:00:37.939 6035-6035/com.example.testmqtt D/mqtt: not
connectedorg.eclipse.paho.android.service.MqttTokenAndroid@d544622
Please fill out the form below before submitting, thank you!
__Android API Version Bug Seen on:Checked on 22 and 24
Android Version Bug Seen on:Checked on 5.1 and 7.0
Description of Bug:
I hosted Mosquitto MQTT broker on Digital Ocean Cloud. Now, I am trying to connect it to the android studio. But it is not connecting to the MQTT broker.I tried with the following code.
Console Log output (if available):