0

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!

  • 1
    Does `lsof -i` show mosquitto bound to 0.0.0.0? How are you starting mosquitto, are you sure it's reading the config file (it will not read it unless explicitly passed the file)? Can you reach the VM from another machine inside the University network? – hardillb Aug 17 '21 at 12:54
  • @hardillb I have updated my question with the output of ```lsof -i```. The VM is definitely reachable from another machine inside the Uni network, as I access and perform all operation through ssh from my personal computer. – Joaquin Peralta Aug 18 '21 at 13:07
  • 1
    What I meant was can you use `mosquitto_sub` from another machine on the University network. It looks like mosquitto is configured properly (bound to 0.0.0.0) which means it is looking like a network/firewall problem and as such not really a question for Stack Overflow. You might get some help on Super User, but most likely you will need to talk to the Uni network team. – hardillb Aug 18 '21 at 13:33
  • @hardillb I have tried communication from another machine in the same network and the problem persists. Therefore, I agree with you that this may be a network related problem. Thank you for your hints! – Joaquin Peralta Aug 19 '21 at 12:00

0 Answers0