rabbit mq server with mosqyitto mqtt client

726 views
Skip to first unread message

gaurav...@jaarwis.com

unread,
Aug 11, 2014, 1:00:51 AM8/11/14
to rabbitm...@googlegroups.com
hi all

Actually  i m trying to use mosquitto client with the rabbit mq server. After making connection it is not working properly, e.g if m pressing the buzzer button twice sometimes thrice from my iphone application then my code is subscribing  from the server and sometimes it works properly but only for a short duration and it is very difficult to detect that what is the error.


Michael Klishin

unread,
Aug 11, 2014, 1:31:32 AM8/11/14
to rabbitm...@googlegroups.com, gaurav...@jaarwis.com


On 11 August 2014 at 09:00:58, gaurav...@jaarwis.com (gaurav...@jaarwis.com) wrote:
> > After making connection it is not working properly, e.g if m
> pressing the buzzer button twice sometimes thrice from my iphone
> application then my code is subscribing from the server and sometimes
> it works properly but only for a short duration and it is very difficult
> to detect that what is the error.

 * What is in RabbitMQ log files?
 * Does your client use the same ID?

Per MQTT spec, if a client with ID = A connects and there's another client
with this client id connected, the server must disconnect the older client.
If you think RabbitMQ MQTT plugin needs to log such cases better, let us
know. 

What's the "button" app you are using? I'm only aware of Mosquitto's command
line helper apps that publish and consume.
--
MK

Staff Software Engineer, Pivotal/RabbitMQ
Message has been deleted
Message has been deleted

gaurav...@jaarwis.com

unread,
Aug 11, 2014, 1:56:29 AM8/11/14
to rabbitm...@googlegroups.com

Actually i am using the adafruit cc3000 chip with arduino to make connection with the rabbit mq server...

Michael Klishin

unread,
Aug 11, 2014, 1:59:13 AM8/11/14
to rabbitm...@googlegroups.com, gaurav...@jaarwis.com
 On 11 August 2014 at 09:56:35, gaurav...@jaarwis.com (gaurav...@jaarwis.com) wrote:
> > Actually i am using the adafruit cc3000 chip with arduino to
> make connection with the rabbit mq server..

According to the code in arduino_node.cpp, you always connect
with the same client ID:

mqttclient.connect("ardcli_1",user,pass)

which means RabbitMQ will drop the earlier connections, as must any other
MQTT broker.

Use different client ids if you need to have multiple connections.

gaurav...@jaarwis.com

unread,
Aug 11, 2014, 2:20:30 AM8/11/14
to rabbitm...@googlegroups.com

Actually i am not doing it for multiple connection right now. Connection with same client id is not working properly.This is the issue

Michael Klishin

unread,
Aug 11, 2014, 2:23:15 AM8/11/14
to rabbitm...@googlegroups.com, gaurav...@jaarwis.com
Can you please be more specific than "not working properly"?

What exactly do you do (it's not clear what "the button" does)?
What are your expectations?

What is in RabbitMQ log files? 

gaurav...@jaarwis.com

unread,
Aug 11, 2014, 4:48:09 AM8/11/14
to rabbitm...@googlegroups.com

ok leave the mobile application part. Actually i have included a rabit mq server  in main server of my company and using mosquitto library client ,i am connecting my cc 3000 chip with server at ip->192.168.245.192 port 1883. After successful completion of connection , i have opened to terminal .In one terminal i have started the server using "mosquitto_sub -d -t topic name -h 192.168.245.192" and in another terminal ,i am using this "mosquitto_pub -d -t topic name - h 192.168.245.192 -m buzzer". The thing which i want is that whenever i use the mosquitt+pub command with buzzer as a parameter it is subscribed by the client code whcih is written in arduino_node.cpp->

uint32_t ip = 3232298432;
    if (!client.connected())
    {
        client = cc3000.connectTCP(ip, 1883);
    }
    char *user="guest";
    char *pass="guest";
    if(client.connected())
    {
        if (mqttclient.connect("ardcli_1",user,pass))
        {
            mqttclient.publish(mqttstream,"online");
            mqttclient.subscribe(mqttstream);
        }
    } 


Michael Klishin

unread,
Aug 11, 2014, 4:53:03 AM8/11/14
to rabbitm...@googlegroups.com, gaurav...@jaarwis.com
On 11 August 2014 at 12:48:15, gaurav...@jaarwis.com (gaurav...@jaarwis.com) wrote:
> > After successful completion of connection , i have opened to
> terminal .In one terminal i have started the server using "mosquitto_sub
> -d -t topic name -h 192.168.245.192"
> and in another terminal ,i am using this "mosquitto_pub -d -t
> topic name - h 192.168.245.192
> -m buzzer".

Note that you are not specifying any client-ids, are you sure that those
tools will, in fact, use two separate IDs? This is of crucial importance
in MQTT.

>The thing which i want is that whenever i use the mosquitt+pub
> command with buzzer as a parameter it is subscribed by the client
> code whcih is written in arduino_node.cpp->

and what actually happens?

Does the mosquitto_sub subscriber receive what's
published?
Do you want *two* subscribers (one mosquitto_sub, one mobile client) receive
a copy of every message published with mosquitto_pub? 

Finally, asking for the 3rd time: what is in RabbitMQ log files?

gaurav...@jaarwis.com

unread,
Aug 11, 2014, 5:05:18 AM8/11/14
to rabbitm...@googlegroups.com

this is the lof file->
=ERROR REPORT==== 11-Aug-2014::19:07:23 ===
connection <0.5280.1>, channel 1 - soft error:
{amqp_error,not_found,
            "no queue 'mqtt-subscription-ardcli_1qos1' in vhost '/'",
            'queue.delete'}

=INFO REPORT==== 11-Aug-2014::19:07:24 ===
accepting MQTT connection (192.168.244.105:33308 -> 192.168.245.192:1883)

=ERROR REPORT==== 11-Aug-2014::19:07:24 ===
connection <0.5299.1>, channel 1 - soft error:
{amqp_error,not_found,
            "no queue 'mqtt-subscription-mosqpub/3719-localhost.qos1' in vhost '/'",
            'queue.delete'}

=INFO REPORT==== 11-Aug-2014::19:07:31 ===
accepting MQTT connection (192.168.244.105:33309 -> 192.168.245.192:1883)

=ERROR REPORT==== 11-Aug-2014::19:07:31 ===
connection <0.5319.1>, channel 1 - soft error:
{amqp_error,not_found,
            "no queue 'mqtt-subscription-mosqpub/3723-localhost.qos1' in vhost '/'",
            'queue.delete'}


gaurav...@jaarwis.com

unread,
Aug 11, 2014, 5:06:45 AM8/11/14
to rabbitm...@googlegroups.com

client id is "ardcli_1" written in mqttclient.connect() function;

Michael Klishin

unread,
Aug 11, 2014, 5:07:43 AM8/11/14
to rabbitm...@googlegroups.com, gaurav...@jaarwis.com
 On 11 August 2014 at 13:05:24, gaurav...@jaarwis.com (gaurav...@jaarwis.com) wrote:
> > =ERROR REPORT==== 11-Aug-2014::19:07:31
> ===
> connection <0.5319.1>, channel 1 - soft error:
> {amqp_error,not_found,
> "no queue 'mqtt-subscription-mosqpub/3723-localhost.qos1'
> in vhost '/'",
> 'queue.delete'}

What RabbitMQ version do you run?

gaurav...@jaarwis.com

unread,
Aug 11, 2014, 5:09:00 AM8/11/14
to rabbitm...@googlegroups.com

rabbit mq version is 3.1.5


Michael Klishin

unread,
Aug 11, 2014, 5:11:20 AM8/11/14
to rabbitm...@googlegroups.com, gaurav...@jaarwis.com
That's not what I was pointing out. Without going into much detail,
every MQTT client must have a separate client-id specific, or chaos and confusion
will quickly follow. Please take my word for it.

You are specifying a client-id in the mobile app but it is hardcoded. This
means that not only every device but also every connection in the app
will use the same client-id. This is pretty bad.

In addition, you don't provide the -i flag to mosquitto_pub and mosquitto_sub.
So they may end up using the same client id. Even if they don't, you rely on
their behaviour which — as far as I can see — is not incredibly well documented
and may change in the future.

The thing you should do before continuing investigating what's going on:
make ALL MQTT connections you create using any library/tool/etc
use a client-id that is explicitly provided and different from the other IDs. 

gaurav...@jaarwis.com

unread,
Aug 11, 2014, 5:12:34 AM8/11/14
to rabbitm...@googlegroups.com

and yes mosquitto_sub function is subscribed the message which i am publishing with mosquitto_pub commmand but it is not subscribed in my code properly.Sometimes i have to publish it twice and sometimes thrice the it is subscribed by my code.

Michael Klishin

unread,
Aug 11, 2014, 5:13:14 AM8/11/14
to rabbitm...@googlegroups.com, gaurav...@jaarwis.com
On 11 August 2014 at 13:09:06, gaurav...@jaarwis.com (gaurav...@jaarwis.com) wrote:
> > rabbit mq version is 3.1.5

Yeah, so something makes RabbitMQ MQTT plugin think it's time to delete the queue
it uses (e.g. connection loss) and that causes channel errors if the queue no
longer exists.

Upgrade ot 3.3.4 and you will no longer see these messages because queue.delete
is idempotent (if that doesn't make sense, don't worry about it). Many other things
were improved in the MQTT plugin since 3.1.5 .

Michael Klishin

unread,
Aug 11, 2014, 5:14:47 AM8/11/14
to rabbitm...@googlegroups.com, gaurav...@jaarwis.com
All of which points out to the same fact: you have to stop using a hard-coded
client-id. And upgrade to RabbitMQ 3.3.4 to avoid hitting an unfortunate 
implementation detail in that version.

gaurav...@jaarwis.com

unread,
Aug 11, 2014, 5:15:15 AM8/11/14
to rabbitm...@googlegroups.com

then where can i find this client id. becaause according to me the id which i told you is client id


Michael Klishin

unread,
Aug 11, 2014, 5:18:06 AM8/11/14
to rabbitm...@googlegroups.com, gaurav...@jaarwis.com
On 11 August 2014 at 13:15:20, gaurav...@jaarwis.com (gaurav...@jaarwis.com) wrote:
> > then where can i find this client id. becaause according to me
> the id which i told you is client id

You provide the id. It can be any unique string < 23 bytes long (and 255 in MQTT 3.1.1/RabbitMQ 3.4).

Your problem is that the id is hardcoded => not unique. 
Reply all
Reply to author
Forward
Message has been deleted
0 new messages