I have the Contiki web demo running on a CC2650 and I'm trying to troubleshooting MQTT and want to make sure I'm properly pointing the node to a local MQTT broker (Mosquitto). Is there anything else I need to do but change the broker IP on the node to the bbbb:: IPv6 address of the broker? I've tested publishing and subscribing between Linux machines using the bbbb:: IPv6 address and it is working. Is there anything I need to do with the Org Id or auth token? I've done an exhaustive search but can't seem to find any specific documentation. Here is the link to the TI tutorial for reference http://processors.wiki.ti.com/index.php/Cc26xx_sw_examples Thanks in advance.
I am now able to answer my question on this and yes you can just point a node a local MQTT broker by pointing to the IPv6 address of the Mosquitto broker. I'm troubleshooting some 6LowPAN packet loss issues which was making the reception of published messages take a long time. Subscribing to the broker for all topics with mosquitto_sub -h localhost -v -t “#” and doing a tcpdump on port 1883 (tcpdump -i eth0 -v -X port 1883) were both helpful in seeing that there was activity.
Related
I’m new in this field and I’m trying to create a device using arduino WiFi Rev 2 and the broker mqtt Mosquitto on an external network.
I’ve already installed Mosquitto on my PC and started it by the prompt. I changed the configuration file of Mosquitto in order to allow the listener on port 1883 and then run on prompt the command mosquitto -c mosquitto.conf -v and it worked.
But when I run netstat-a on the prompt, the port 1883 doesn’t appear on the address of the external network. What can I do to fix it ?
There’s the conf file I added
per_listener_settings true
listener 1883
protocol mqtt
allow_anonymous true
listener 8083
protocol websockets
allow_anonymous true
Thanks for the your attention, hope to find a solution!
With the configuration you have provided, mosquitto will bind to ALL addresses, this will be signified by it binding to 0.0.0.0:1883 (and 0.0.0.0:8083)
So there is nothing to fix. Assuming no firewall/NAT between the Arduino and the machine running the broker it should just connect.
I am having some problems with my Mosquitto MQTT broker which I do not understand. I had setup another Mosquitto broker in a Google Cloud Ubuntu 20.04 VM and it was working properly. I have moved to a self-managed Ubuntu 20.04 VM in my university and have not been able to connect to the broker ever since. A little background on the current setup:
netfilter-persistent firewall (am unsure of the exact name of the firewall, this is the name of th service) has port 1883 open
ufw is inactive
the university has 2 levels in the firewall, one in the VM and one external. I have asked for the opening of ports 1883 (I am aware that only port 8883 should be open but this is temporary until I solve my issue)
the VM is accessible from outside the LAN of the university, as checked in https://www.yougetsignal.com/tools/open-ports/
I have an Apache webpage running and it is also accessible externally
I have NodeRED using port 1880 and it is also accessible externally
My Mosquitto conf file looks like the following. For the time being, I am not using TLS authentication, as I first need to solve the issue with the connection.
allow_anonymous false
password_file /etc/mosquitto/passwd
listener 1883 0.0.0.0
However, I have not been able to enable the communication when using either the server IP or the domain name. If I attempt to connect using localhost, everything works:
~$ mosquitto_sub -h localhost -t test -p 1883 -u "XX" -P "XX" -d
Client (null) sending CONNECT
Client (null) received CONNACK (0)
Client (null) sending SUBSCRIBE (Mid: 1, Topic: test, QoS: 0, Options: 0x00)
Client (null) received SUBACK
Subscribed (mid: 1): 0
If I attempt to connect with the domain name, I never receive an acknowledgment and the connection is never established:
~$ mosquitto_sub -h domain.com -t test -p 1883 -u "XX" -P "XX" -d
Client (null) sending CONNECT
Client (null) sending CONNECT
Client (null) sending CONNECT
Client (null) sending CONNECT
Client (null) sending CONNECT
Mosquitto seems to be properly bound when running the lsof -i command in the console:
mosquitto 2177304 mosquitto 5u IPv4 10127120 0t0 TCP *:1883 (LISTEN)
mosquitto 2177304 mosquitto 7u IPv4 10127251 0t0 TCP localhost:1883->localhost:47236 (ESTABLISHED)
I would appreciate it if anyone could guide me into what could be the root of my issue. If more information is needed regarding my setup, I will gladly provide it.
Thanks in advance to all!
I coded an Android application for publishing and suscribing to Mosquitto broker using MQTT paho library and I tested it under different scenarios.
I've already tested my application and it works perfectly in a LAN scenario, but it doesn't work anymore when the message comes from remote. I've also configured the forwarding ports on the router of the IoT device network.
The problem is when publishing a message to IoT device (Pico-pi-iMX7 with Android Things running on it), and the message is being sent from remote broker.
I tested recieving the message on a computer under the same network as the IoT device by the forwarding rules and it works. Since the device is unix-based, I used iptables to be sure to accept all the network traffic with the following comands as super user:
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -A INPUT -p tcp -sport 1883 -j ACCEPT
When I send the message, I get the following error:
Error: Cannot establish a connection with the target - Connection refused.
Any ideas?
When I publish and subscribe at localhost its work fine.
When I try from my PC at home I just can't connect to the broker.
open TCP port in/out at security group - 1883 8883 8080
open the ports also at my ec2 instance firewall...
what is the problem? I use the public DNS by amazon as I think I should...
This is an exercise at diagnosing network problems:
1) netstat -a -n | grep 1883
will tell you whether your broker is configured correctly
2) wireshark packet capture will tell you whether your system is receiving packets at the specific port
You will not get an answer until you at least do those.
I have a local (OSX 11) mosquitto broker (1.4.7) running with the following config:
connection test
address test.mosquitto.org
topic in_topic in 0
topic out_topic out 0
try_private false
notifications false
bridge_attempt_unsubscribe true
I got the conf settings form here: bridge local mosquitto to cloud broker (thanks)
I now have 3 terminals.
A: subscribed to test.mosquitto.org directly using a ruby script and ruby-mqtt.
B: subscribed to local broker with mosquitto_sub -t in_topic
C: publishes using this command: mosquitto_pub -h test.mosquitto.org -t in_topic -m "hello world1"
Now, when I do this I get the response in A and B so that makes me think my bridging connection is working. However, if I drop the -h test.mosquitto.org I don't get the message from A. So, the message is only going to that broker (test.mosquitto.org) if I include the -h option.
On the other hand, if I stop the local mosquitto broker and then run the same command including the -h option then the A still gets the message and B doesn't. B actually doesn't even start up since the connection is refused since local broker is not running.
So, my question is, does this configuration actually establish that the brokers are bridging? I am not sure.
Update:
As hardillb pointed out my mistake was that the topic that I was using to publish was not configured to publish out to the other broker. When I updated the conf to topic in_topic out 0 I succeeded in getting the message directly from the test.mosquitto.org broker without including the -h test.mosquitto.org in other words. The message propagated based on the configuration.
The documentation for what I got wrong can be found under the bridging section here: http://mosquitto.org/man/mosquitto-conf-5.html
You won't get anything in terminal A from running the following
mosquitto_pub -t in_topic -m "hello world1"
Because your bridge is set up to only forward things on out_topic from the local broker to the remote (test.mosquitto.org)
topic out_topic out 0
I would change your config if you can:
notifications true
This will publish to $SYS/broker/connections//state - either a 1 or 0 depending on whether the connection is active. This happens on both the remote and the local broker.