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 asked our IT support if there is any firewall on the router. He is gonna check today. But I tried it with my phone’s network (as hotspot over 3G) and the same issue..


From: paho-dev-bounces@xxxxxxxxxxx [mailto:paho-dev-bounces@xxxxxxxxxxx] On Behalf Of Seth Hoenig
Sent: den 6 februari 2014 03:02
To: General development discussions for paho project
Subject: Re: [paho-dev] help socket timeout exception mqtt android


Are you certain there is no firewall on your router/switch?  Using ping is unfortunately useless for detecting port issues (it doesn't even use tcp or udp), and many firewalls don't block ping traffic anyway.

When you connected with the emulator, was that using an address in 10.0.2/24 ?  If so that trick doesn't work for anything not running on the host machine.


On Wed, Feb 5, 2014 at 2:54 PM, Golnaz Makhtoumi <Golnaz.Makhtoumi@xxxxxx> wrote:

Yes I have that permission.


Odd enough I tried my code on emulator (for first time) (I was using real device before) and it worked!!

Anybody knows how to make it work on real android device?!!!




From: paho-dev-bounces@xxxxxxxxxxx [mailto:paho-dev-bounces@xxxxxxxxxxx] On Behalf Of Benjamin Cabé
Sent: den 5 februari 2014 19:07
To: General development discussions for paho project
Subject: 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?

paho-dev mailing list


Back to the top