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
Related
We are developing and IoT Edge application where we need to run mosquitto broker in a embedded linux gateway device. The edge broker is bridged to a cloud MQTT broker. Other devices in the edge network publishes to the edge mosquitto broker and mosquitto will publish it to the cloud. The edge gateway is located at a site where network connectivity is very constrained.
An edge device is sending 28KB payload to the mosquitto broker at 1 message per 5 seconds frequency. We could see that the internal queue of the mosquitto goes on increasing ('$SYS/broker/messages/stored'). It increases to fully utilize the gateway memory and then mosquitto crashes.
When we enabled logging in mosquitto and checked, we could see that
The time duration between PUBLISH and PUBACKs are huge
Because of this huge delay mosquitto is resending the messages multiple times
See logs below for a specific message:
1591704254: Sending PUBLISH to local.clientid (d0, q1, r0, m572, 'toCLOUD/Basic', ... (32768 bytes))
1591704275: Sending PUBLISH to local.clientid (d1, q1, r0, m572, 'toCLOUD/Basic', ... (32768 bytes))
1591704296: Sending PUBLISH to local.clientid (d1, q1, r0, m572, 'toCLOUD/Basic', ... (32768 bytes))
1591704317: Sending PUBLISH to local.clientid (d1, q1, r0, m572, 'toCLOUD/Basic', ... (32768 bytes))
1591704338: Sending PUBLISH to local.clientid (d1, q1, r0, m572, 'toCLOUD/Basic', ... (32768 bytes))
1591704359: Sending PUBLISH to local.clientid (d1, q1, r0, m572, 'toCLOUD/Basic', ... (32768 bytes))
1591704380: Sending PUBLISH to local.clientid (d1, q1, r0, m572, 'toCLOUD/Basic', ... (32768 bytes))
1591704401: Sending PUBLISH to local.clientid (d1, q1, r0, m572, 'toCLOUD/Basic', ... (32768 bytes))
1591704422: Sending PUBLISH to local.clientid (d1, q1, r0, m572, 'toCLOUD/Basic', ... (32768 bytes))
1591704526: Received PUBACK from local.clientid (Mid: 572)
1591704597: Received PUBACK from local.clientid (Mid: 572)
1591704680: Received PUBACK from local.clientid (Mid: 572)
1591704750: Received PUBACK from local.clientid (Mid: 572)
1591704838: Received PUBACK from local.clientid (Mid: 572)
1591704901: Received PUBACK from local.clientid (Mid: 572)
1591704975: Received PUBACK from local.clientid (Mid: 572)
1591705039: Received PUBACK from local.clientid (Mid: 572)
1591705120: Received PUBACK from local.clientid (Mid: 572)
To recreate this issue I tried using "mosquitto_pub" command in the geteway with same connection information like this:
for i in `seq 1 1000`
do
echo $JSON
done | mosquitto_pub -h broker.cloud.com -t 'toCLOUD/TEST' -l -q 1
But I was not able see the same delay or duplication in the "mosquitto_pub"
What would be the best solution for this? Can I increase the publish timeout for mosquitto bridge? Any other alternative solution?
Mosquitto version: 1.4.14
Mosquitto Bridge config:
connection MQTT_Bridge
address cloud.broker.com:8883
topic ToCloud/# out 2 "" ""
remote_clientid abcd
keepalive_interval 60
bridge_cafile /certs/ca
Backhaul: Satellite (200kbps not sure )
Cloud broker : eMQTT
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 am new to Mosquitto. I have installed Mosquitto and Mosquitto Client in Ubuntu. I am trying to subscribe with client-id also publish with client-id, please look the command that I have run in console, but unfortunately, the subscriber is not receiving the message.
Subscription
mosquitto_sub -h localhost -t temp/city1 -c -q 2 --id client-one
Publish
mosquitto_pub -h localhost -t temp/city1 -m "32 Celsius" -q 2 --id client-one
but if I Publish message without client id the subscriber is receiving message, so please help me where I did the mistake?
As mentioned in the comment, clientIds are just that, they are a unique identifier for each client connected to the broker.
ClientIds need to be totally unique, if a second client tries to connect with a clientid that is already connected the broker must disconnect the first client to allow the second to connect (this is dictated by the specification). In the example you have given the subscriber will be disconnected before it receives the message published by the second.
Messages are published to topics and clients can subscribe to these topics (or patterns of topics with wildcards)
So using the mosquitto command line tools you can do the following:
mosquitto_sub -v -t 'foo/bar'
This will subscribe to the topic foo/bar and will print out the topic and then message when ever a message is published to that topic. To publish a message containing the string testing you would use:
mosquitto_pub -t 'foo/bar' -m 'testing'
The mosquitto command line tools will generate random clientids if none are provided on the command line.
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.