Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] help socket timeout exception mqtt android

I am sorry if this sounds like a stupid question but did you put the INTERNET permission in your Manifest?

Le 5 févr. 2014 16:50, Golnaz Makhtoumi <Golnaz.Makhtoumi@xxxxxx> a écrit :

What Am I doing wrong?

Im trying to connect to a mosquito broker on my laptop via an android application.  I can ping between two devices so they are connected under same network. There is no firewall on my laptop.


When I run the app and press start button (which starts the mqtt service) after 5 or 6 seconds of showing pressed button, I get:

MqttException (0) – failed to connect to / my laptops Ip address (port 1883) after 3000ms



            public int onStartCommand(Intent intent, int flags, int startId) {

                         // TODO Auto-generated method stub

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

                         try {

                                     Toast.makeText(this, "before try", Toast.LENGTH_LONG).show();

                                     client = new MqttClient("tcp://here I put my laptop’s IP address:1883", "pahomqttpublish2", new MemoryPersistence());

                         //          client = new MqttClient("", "pahomqttpublish2", new MemoryPersistence());

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

                               Toast.makeText(this, "after creating the mqttclient", Toast.LENGTH_LONG).show();


                               MqttMessage message = new MqttMessage();

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

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

                             // client.disconnect();

                             } catch (MqttException e) {

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




                                     return super.onStartCommand(intent, flags, startId);




What am I doing wrong?

Back to the top