2

I installed the Mosquitto MQTT on my Pi and I want to test it on my Windows via Putty.

What is my MQTT server IP address and port ?

I tried ifconfig but it shows:

 inet addr : as hex like fe80::465d.... etc.
  • Which MQTT (mosquito) or some other implementation? can you post your /etc/network/interface file – Shan-Desai Mar 10 '17 at 13:50
  • Sorry i forgot it. Its mosquitto – PBSDR Mar 10 '17 at 14:07
  • I think you do not have any IP address, your server is binded on the localhost something like 127.0.0.1 or ::1. the fe80:: is your IPv6 Link-Local Address. – Shan-Desai Mar 10 '17 at 14:12
  • So what should i enter to puttys ip area ? – PBSDR Mar 10 '17 at 14:14
  • add the IP address of the Pi in your /etc/mosquitto/mosquitto.conf file and it will be a server with that particular IP – Shan-Desai Mar 10 '17 at 14:22
4

According to the man page for Mosquitto It is dominated by a Configuration file which is /etc/mosquitto/mosquitto.conf.

According to the man page for the mosquitto.conf:

bind_address address

Listen for incoming network connections on the specified IP address/hostname only. This is useful to restrict access to certain network interfaces. To restrict access to mosquitto to the local host only, use "bind_address localhost". This only applies to the default listener. Use the listener variable to control other listeners.

listener port [bind address/host]

Listen for incoming network connection on the specified port. A second optional argument allows the listener to be bound to a specific ip address/hostname. If this variable is used and neither the global bind_address nor port options are used then the default listener will not be started.

The bind address/host option allows this listener to be bound to a specific IP address by passing an IP address or hostname. For websockets listeners, it is only possible to pass an IP address here.

Hence your current IP address is the localhost IP address generally 127.0.0.1 for IPv4 and or ::1 for IPv6. This can be seen from ifconfig lo.

Default port number for mosquitto is 1883 according to the man page

fe80:: addresses are IPv6 Link-Local Addresses which exist for each IPv6 enabled device on your Pi.

It is recommended to change the IP address and port values in your mosquitto.conf for your desired functionality and restart mosquitto again:

 /etc/init.d/mosquitto restart
  • I added "bind_address 192.168.1.29" and "listener port[192.168.1.29/1883]" to mosquitto.conf file . I restarted service and when i try to sub and pub to topic it says "Error:Connection refused" . – PBSDR Mar 11 '17 at 8:09
  • Okay i changed ssh settings to enabled in preferences/interfaces menu. It's solved. Also added pi@ before ip address . Thanks a lot! – PBSDR Mar 11 '17 at 8:26
  • If you think the answer is what you wanted then accept it for future reference. – Shan-Desai Mar 11 '17 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.