Publusher sends a message -m "hello" to the topic -t hello using the command mosquitto_pub -h 172.17.*.* -t hello -m "hello" -d. The subscriber sees the message -m "hello" only if the connection to the topic -t hello is active. However, if the subscriber is not subscribed to the -t hello topic and the publisher still sends messages on the -t hello topic, then when you try to subscribe to this topic mosquitto_sub -h 172.17. *. * -t hello subscriber does not receive sent messages from publisher.
After reading the documentation, breaking a couple of brokers, I achieved only the fact that you can see the last message if you put the flag on the publisher -r like this - -mosquitto_pub -h 172.17. *. * -r -t hello -m "hello". I configured mosquitto.conf, because I thought that the main changes, an example of the current problem, can only be achieved through it.
How can I solve such a problem, I would like to see all missed messages from publisher when i resubscribe to the topic?
You need to use the QOS (Quality of Service) values for the messages. By default QOS is set to 0 which is basically fire and forget, QOS 1 is ensure delivery (but could mean delivered more than once). QOS 2 is ensured delivery only once.
It's needs pointing out that QOS is between 1 client and the broker, so this can be between the publisher and the broker, or the broker and a subscriber independently. (e.g. you can publish at QOS 0 and then subscribe to the topic at QOS 2).
For message queuing for offline clients, the client needs to have been subscribed at QOS 1 or QOS 2 and when it reconnects it needs to have it's cleanSession flag set to false and use the same client id.
MQTT brokers will not queue messages for clients that have never connected before.
With mosquitto_sub and mosquitto_pub you can set the QOS level with -q option and you can set the client id with the -i option. To set the clean session flag to false for mosquitto_sub you should use the -c option
I am trying to setup MQTT bridge to cloudmqtt.com. Local bridge running on raspbian.
I want to push local topics (UP/site1/#) to cloudmqtt broker as it is & pull remote topics ('Down/site1/#') to local bridge.
Tried following configs, but didn't work
topic UP/site1/# out 2
topic Down/site1/# in 2
topic UP/site1/# out 2 UP/site1/ UP/site1/
topic Down/site1/# in 2 Down/site1/ Down/site1/
topic UP/site1/# out 2 "" ""
topic Down/site1/# in 2 "" ""
Here is the full config
connection cloudmqtt
address *****.cloudmqtt.com:1883
bridge_protocol_version mqttv311
remote_username ****
remote_password ****
try_private false
start_type automatic
notifications false
cleansession false
topic UP/site1/# out 2
topic Down/site1/# in 2
Bridge log messages :
1545695073: Received PINGREQ from 8de7c6e8-4c6a-49b0-9aaa-5816aa9504901545604132782
1545695073: Sending PINGRESP to 8de7c6e8-4c6a-49b0-9aaa-5816aa9504901545604132782
1545695073: Received PUBLISH from pod01 (d0, q0, r0, m0, 'UP/site01/pod01', ... (191 bytes))
1545695076: Received PUBLISH from pod01 (d0, q0, r0, m0, 'UP/site01/pod01', ... (190 bytes))
1545695079: Received PUBLISH from pod01 (d0, q0, r0, m0, 'UP/site01/pod01', ... (190 bytes))
1545695082: Received PUBLISH from pod01 (d0, q0, r0, m0, 'UP/site01/pod01', ... (191 bytes))
1545695083: Received PINGREQ from 8de7c6e8-4c6a-49b0-9aaa-5816aa9504901545604132782
1545695083: Sending PINGRESP to 8de7c6e8-4c6a-49b0-9aaa-5816aa9504901545604132782
1545695085: Received PUBLISH from pod01 (d0, q0, r0, m0, 'UP/site01/pod01', ... (189 bytes))
1545695089: Bridge ff001.cloudmqtt sending CONNECT
1545695089: Received CONNACK on connection local.ff001.cloudmqtt.
1545695089: Bridge local.ff001.cloudmqtt sending UNSUBSCRIBE (Mid: 12, Topic: UP/site1/#)
1545695089: Bridge local.ff001.cloudmqtt sending SUBSCRIBE (Mid: 13, Topic: Down/site1/#, QoS: 2)
1545695089: Bridge local.ff001.cloudmqtt doing local SUBSCRIBE on topic UP/site1/#
1545695089: Received UNSUBACK from local.ff001.cloudmqtt
1545695089: Received SUBACK from local.ff001.cloudmqtt
1545695090: No will message specified.
1545695090: Sending CONNACK to pod01 (0, 0)
1545695090: No will message specified.
1545695090: Sending CONNACK to 8de7c6e8-4c6a-49b0-9aaa-5816aa9504901545604132782 (0, 0)
1545695092: Received PUBLISH from pod01 (d0, q0, r0, m0, 'UP/site01/pod01', ... (190 bytes))
1545695095: Received PUBLISH from pod01 (d0, q0, r0, m0, 'UP/site01/pod01', ... (190 bytes))
1545695098: Received PUBLISH from pod01 (d0, q0, r0, m0, 'UP/site01/pod01', ... (191 bytes))
1545695100: Received PINGREQ from 8de7c6e8-4c6a-49b0-9aaa-5816aa9504901545604132782
1545695100: Sending PINGRESP to 8de7c6e8-4c6a-49b0-9aaa-5816aa9504901545604132782
1545695101: Received PUBLISH from pod01 (d0, q0, r0, m0, 'UP/site01/pod01', ... (191 bytes))
1545695104: Received PUBLISH from pod01 (d0, q0, r0, m0, 'UP/site01/pod01', ... (192 bytes))
1545695107: Received PUBLISH from pod01 (d0, q0, r0, m0, 'UP/site01/pod01', ... (191 bytes))
1545695110: Received PINGREQ from 8de7c6e8-4c6a-49b0-9aaa-5816aa9504901545604132782
1545695110: Sending PINGRESP to 8de7c6e8-4c6a-49b0-9aaa-5816aa9504901545604132782
1545695110: Received PUBLISH from pod01 (d0, q0, r0, m0, 'UP/site01/pod01', ... (191 bytes))
1545695113: Received PUBLISH from pod01 (d0, q0, r0, m0, 'UP/site01/pod01', ... (192 bytes))
I have mosquitto_1.5.5
If I remove out/in wildcard and replace it with topic # both 2 it works. But I don't want to pull all remote topics, only specific to site (Down/site1/#) and push all local topics to remote. in above logs from bridge, looks like its not publishing local topics to remote cloudMQTT.
anyone know what I am missing here do I need to change anything on remote MQTT (cloudmqtt instance) ?
You are setting the bridge up with UP/site1/# and publishing to UP/site01/...
The problem is the site1 != site01
I have a problem using mosquitto bridge.
I have two ubuntu 14.04 virtual machines: B1 and B2
I have simply the following config file on B1:
connection mylocalhost
address serverIpAdress:1883
topic # both 2
B1 connects to B2 correctly
I subscribe on both machines with:
mosquitto_sub -d -v -t "#" -h localhost
When a message is published on B1 I did receive the publish on B1 but it is not received on B2.
On the other way it is working. When a message is published on B2, it is received on B2 AND B1
Do you have an idea what this could be ?
for information:
when I publish a message on B1
I have nothing on B2 broker,
and the following on B1 broker:
1539876297: Received PUBLISH from mosq_pub_3027_ubuntu-V (d0, q2, r0, m1, 'remote/titi/', ... (4 bytes))
1539876297: Sending PUBREC to mosq_pub_3027_ubuntu-V (Mid: 1)
1539876297: Received PUBREL from mosq_pub_3027_ubuntu-V (Mid: 1)
1539876297: Sending PUBCOMP to mosq_pub_3027_ubuntu-V (Mid: 1)
1539876297: Received DISCONNECT from mosq_pub_3027_ubuntu-V
So I have setup a two MQTT brokers [say 'A' and 'B'](setup using cloud mqtt) where 'B' is bridged to 'A' (by a two way bridge). When I publish to a topic to 'A' it shows up under 'A' then shows up under 'B' (as expected). But, if i publish to 'B' it shows up under 'B' then under 'A' then a duplicate publish is seen under 'B'. Is there some flag I need to set or setting i need to change to prevent this ?
How did you initiate the bridge?
You need to define a local prefix and a different remote prefix for the connection. Do not mix that up with the meaning of "local" or "remote", but thake them as the names of those branches that should be mirrored to the other broker.
This prevents the brokers from looping the very same messages again and again.
Lets say your "A" broker sends commands over the branch order/command
and your "B" broker holds sensor values at home/sensor
Then if you publish a message to order/command/ on broker "A", you will see this message unter the same branch order/command/ at broker "B".
Also every sensor value thay may be published to home/sensor/ at broker "B" will be mirrored to home/sensor/ at broker "A"
mosquitto.conf: (Raspberry "A" is 192.168.1.100)
connection raspi-PC
address 192.168.1.110:1883
topic # both 0 order/command/ home/sensor/
Then this will work:
client1 : mosquitto_sub -h 192.168.1.110 -t order/command/#
client2 : mosquitto_sub -h 192.168.1.100 -t home/sensor/#
clientA : mosquitto_pub -t order/command/message -m "Hello from A"
clientB : mosquitto_pub -t home/sensor/temp -m "22.5C"
client1 --> order/command/message/"Hello from A"
client2 --> home/sensor/temp/"22.5C"
You see that client1 and client2 are cross subscribers to broker "A" and "B" and they get all branch and subbranch messages, but they are not necessarily local to the brokers.
On clientA and clientB I used the local client to send the message to the local broker.
I am using RYU controller for SDN Setup. I want to monitor basic openflow handshake messages but i have failed to do so..
Here are the steps i do after install of mininet, wireshark and ryu.
./bin/ryu-manager --verbose ryu/app/simple_switch_13.py
step 2: start virtual network
sudo mn --top single,3 --man --controller remote --switch ovsk,Protocols=OpenFLow13
Now no traffic shows up in my wireshark.. I am using wireshark version 1.12 which has an openflow dissector installed in it.
When i use capture loop it shows the request and reply packets, but i want to see "Feature Request" From ryu controller in wireshark
Here is what i did:
Be sure "openvswitch-testcontroller" is down:
yavuz#ubuntu:/tmp$ service --status-all | grep openv
[ + ] openvswitch-switch
[ - ] openvswitch-testcontroller
Run ryu application:
yavuz#ubuntu:~/ryu$ pwd
/home/yavuz/ryu
yavuz#ubuntu:~/ryu$ sudo ryu-manager --verbose ryu/app/example_switch_13.py
lzma module is not available
Registered VCS backend: git
Registered VCS backend: hg
Registered VCS backend: svn
Registered VCS backend: bzr
loading app ryu/app/example_switch_13.py
Before mininet run tcpdump for lo (not eth0 or like that)
sudo tcpdump -i lo -w ryu-local.cap
Run mininet:
yavuz#ubuntu:/tmp$ sudo mn --topo single,3 --controller=remote --mac
*** Creating network
*** Adding controller
Connecting to remote controller at 127.0.0.1:6653
*** Adding hosts:
h1 h2 h3
*** Adding switches:
s1
*** Adding links:
(h1, s1) (h2, s1) (h3, s1)
*** Configuring hosts
h1 h2 h3
*** Starting controller
c0
*** Starting 1 switches
s1 ...
*** Starting CLI:
mininet> h1 ping h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=8.38 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.228 ms
Stop the trace and open it.
Hope this helps.
In short => you can't.
Feature request/replyis part of openflow not part of IP stack. So, its embedded in the packets of TCP/IP model.