MQTT plugin with Paho C Library - messages not received?

236 views
Skip to first unread message

Heloise Chevalier

unread,
Oct 18, 2017, 2:22:14 AM10/18/17
to rabbitmq-users

HI,


I am trying to use RabbitMQ's MQTT plugin, using the C library from Eclipse Paho. For now all I am trying to do is send a simple "Hello World" message to get used to manipulate RabbitMQ and MQTT.


I tried running the asynchronous examples from Paho (http://www.eclipse.org/paho/files/mqttdoc/MQTTAsync/html/subscribe.html & http://www.eclipse.org/paho/files/mqttdoc/MQTTClient/html/pubasync.html), it compiled fine but nothing happens, I don't see any message being received on the subscriber side and there is nothing to display on RabbitMQ's management interface. There is also nothing in the log file, the last thing reported there is the enabling of the MQTT plugin.


I am using a VM running CentOS 6 and RabbitMQ 3.6.12 with Erlang 20.0. I ran the publisher and the subscriber in two different files, I ran the subscriber code first. Clearly I am missing something, but I find it difficult to find any ressources or examples on using RabbitMQ - MQTT with a C library and I can't see what I am missing. Sorry if my question seems naive, I am quite new to all of this.


Thanks in advance.

Michael Klishin

unread,
Oct 18, 2017, 4:33:12 AM10/18/17
to rabbitm...@googlegroups.com
If there is nothing in the log file, it means there were no successful connections (or they sent
no data beyond the TCP 3-way handshake).

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Heloise Chevalier

unread,
Oct 18, 2017, 4:46:20 AM10/18/17
to rabbitm...@googlegroups.com
I tried again, this time I got Failed to connect, return code 4 after running the subscriber and publisher code, the log filed indicated MQTT login failed for "guest" auth_failure: Refused. As I had no user "guest" I created one, set all the permissions for that user and tried to run the code again. 

Now this is what I got after running the publisher :
Subscribing to topic MQTT Examples
for client ExampleClientSub using QoS1

Press Q<Enter> to quit


Connection lost
     cause: (null)


And this is what I found in the log file :
=INFO REPORT==== 18-Oct-2017::10:21:44 ===
MQTT vhost picked using plugin configuration or default

=ERROR REPORT==== 18-Oct-2017::10:21:44 ===
Channel error on connection <0.768.0> (127.0.0.1:59806 -> 127.0.0.1:1883, vhost: '/', user: 'guest'), channel 2:
operation queue.delete caused a channel exception access_refused: access to queue 'mqtt-subscription-ExampleClientSubqos1' in vhost '/' refused for user 'guest'

=INFO REPORT==== 18-Oct-2017::10:21:44 ===
accepting MQTT connection <0.765.0> (127.0.0.1:59806 -> 127.0.0.1:1883)

=ERROR REPORT==== 18-Oct-2017::10:21:44 ===
** Generic server <0.765.0> terminating
** Last message in was {inet_async,#Port<0.43693>,4561,
                           {ok,<<130,18,0,1,0,13,77,81,84,84,32,69,120,97,
                                 109,112,108,101,115,1>>}}
** When Server state == {state,#Port<0.43693>,
                         "127.0.0.1:59806 -> 127.0.0.1:1883",true,undefined,
                         true,running,
                         {none,<0.787.0>},
                         <0.764.0>,false,none,
                         {proc_state,#Port<0.43693>,
                          {dict,0,16,16,8,80,48,
                           {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
                           {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],
                             []}}},
                          {undefined,undefined},
                          {0,nil},
                          {0,nil},
                          undefined,1,"ExampleClientSub",true,undefined,
                          {<0.775.0>,undefined},
                          <0.768.0>,<<"amq.topic">>,
                          {amqp_adapter_info,
                           {0,0,0,0,0,65535,32512,1},
                           1883,
                           {0,0,0,0,0,65535,32512,1},
                           59806,<<"127.0.0.1:59806 -> 127.0.0.1:1883">>,
                           {'MQTT',"N/A"},
                           [{channels,1},
                            {channel_max,1},
                            {frame_max,0},
                            {client_properties,
                             [{<<"product">>,longstr,<<"MQTT client">>}]},
                            {ssl,false}]},
                          none,<0.309.0>,
                          {auth_state,<<"guest">>,
                           {user,<<"guest">>,[],
                            [{rabbit_auth_backend_internal,none}]},
                           <<"/">>},
                          #Fun<rabbit_mqtt_processor.0.107556512>},
                         <0.768.0>,
                         {state,fine,5000,
                          #Ref<0.3103545942.1767374850.80791>}}
** Reason for termination == 
** {amqp_error,access_refused,
               "access to topic 'MQTT Examples' in vhost '/' refused for user 'guest'",
               none}

=INFO REPORT==== 18-Oct-2017::10:22:35 ===
MQTT vhost picked using plugin configuration or default

=ERROR REPORT==== 18-Oct-2017::10:22:35 ===
Channel error on connection <0.807.0> (127.0.0.1:59824 -> 127.0.0.1:1883, vhost: '/', user: 'guest'), channel 2:
operation queue.delete caused a channel exception access_refused: access to queue 'mqtt-subscription-ExampleClientPubqos1' in vhost '/' refused for user 'guest'

=INFO REPORT==== 18-Oct-2017::10:22:35 ===
accepting MQTT connection <0.804.0> (127.0.0.1:59824 -> 127.0.0.1:1883)

=ERROR REPORT==== 18-Oct-2017::10:22:35 ===
** Generic server <0.804.0> terminating
** Last message in was {inet_async,#Port<0.43940>,4606,
                           {ok,<<50,29,0,13,77,81,84,84,32,69,120,97,109,112,
                                 108,101,115,0,1,72,101,108,108,111,32,87,
                                 111,114,108,100,33>>}}
** When Server state == {state,#Port<0.43940>,
                         "127.0.0.1:59824 -> 127.0.0.1:1883",true,undefined,
                         true,running,
                         {none,<0.825.0>},
                         <0.803.0>,false,none,
                         {proc_state,#Port<0.43940>,
                          {dict,0,16,16,8,80,48,
                           {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
                           {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],
                             []}}},
                          {undefined,undefined},
                          {0,nil},
                          {0,nil},
                          undefined,1,"ExampleClientPub",true,undefined,
                          {<0.813.0>,undefined},
                          <0.807.0>,<<"amq.topic">>,
                          {amqp_adapter_info,
                           {0,0,0,0,0,65535,32512,1},
                           1883,
                           {0,0,0,0,0,65535,32512,1},
                           59824,<<"127.0.0.1:59824 -> 127.0.0.1:1883">>,
                           {'MQTT',"N/A"},
                           [{channels,1},
                            {channel_max,1},
                            {frame_max,0},
                            {client_properties,
                             [{<<"product">>,longstr,<<"MQTT client">>}]},
                            {ssl,false}]},
                          none,<0.309.0>,
                          {auth_state,<<"guest">>,
                           {user,<<"guest">>,[],
                            [{rabbit_auth_backend_internal,none}]},
                           <<"/">>},
                          #Fun<rabbit_mqtt_processor.0.107556512>},
                         <0.807.0>,
                         {state,fine,5000,
                          #Ref<0.3103545942.1767374850.80896>}}
** Reason for termination == 
** {amqp_error,access_refused,
               "access to topic 'MQTT Examples' in vhost '/' refused for user 'guest'",
               none}

I don't understand why the access is being refused. Is there anything I am missing? 

Thanks,

Héloïse


To post to this group, send email to rabbitm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ

--
You received this message because you are subscribed to a topic in the Google Groups "rabbitmq-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rabbitmq-users/L9Alxr5ZBCM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rabbitmq-users+unsubscribe@googlegroups.com.

Michael Klishin

unread,
Oct 18, 2017, 5:02:53 AM10/18/17
to rabbitm...@googlegroups.com
access to queue 'mqtt-subscription-ExampleClientSubqos1' in vhost '/' refused for user 'guest'

is very confusing as ‘guest’ has full access to the default vhost (‘/‘) by default.
But both can be deleted and permissions could have been cleared.

See rabbitmqctl man page, specifically the set_permissions command.

rabbitmqctl set_permissions -p “/“ guest “.*” “.*” “.*”

should restore the permissions.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.

Heloise Chevalier

unread,
Oct 18, 2017, 5:09:35 AM10/18/17
to rabbitm...@googlegroups.com
It worked, thank you!

One thing I don't understand now is how to access as another user? Do we have to always access the queues through the user guest? If so, what is the point of having other users?

Thanks again for your answer,

Héloïse

Arnaud Cogoluègnes

unread,
Oct 18, 2017, 5:17:16 AM10/18/17
to rabbitm...@googlegroups.com
Have a look at [1]. The MQTT client library should let you specify a username, otherwise the default_user configuration entry is used and defaults to guest.

Reply all
Reply to author
Forward
0 new messages