Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] Help! Paho MQTT Android Application

Hi All,


I want to stablish a connection to local broker (Mosquitto) by MQTT.

The simple java project is working and I can publish a message.


But now when I want to use the same concept in Android project, it only goes to exception.

Here is the main code inside the (which is a service)



            public void onCreate() {

                         // TODO Auto-generated method stub


            Toast.makeText(this, "My Service Created", Toast.LENGTH_LONG).show();

                         try {

                               client = new MqttClient("tcp://localhost:1883", "pahomqttpublish2");


                               MqttMessage message = new MqttMessage();

                               message.setPayload("A single wessage".getBytes());

                               client.publish("pahodemo/test", message);


                             } catch (MqttException e) {

                               Toast.makeText(this, "went to exception", Toast.LENGTH_LONG).show();






It seems like it does go into try but cannot create instance of MqttClient and then throws exception.


In logcat under syste,.err tag I get MqttException(0) at

And so on..


What am I doing wrong?


Thanks in advance


Back to the top