Mosquitto: Starting in local only mode

早过忘川 提交于 2021-01-16 04:13:37

问题


I have a virtual machine that is supposed to be the host, which can receive and send data. The first picture is the error that I'm getting on my main machine (from which I'm trying to send data from). The second picture is the mosquitto log on my virtual machine. Also I'm using the default config, which as far as I know can't cause these problems, at least from what I have seen from other examples. I have very little understanding on how all of this works, so any help is appreciated.

What I have tried on the host machine:

  1. Disabling Windows defender
  2. Adding firewall rules for "mosquitto.exe"
  3. Installing mosquitto on a linux machine

First error

Second error

Netstat info


回答1:


Starting with the release of Mosquitto version 2.0.0 (you are running v2.0.2) the default config will only bind to localhost as a move to a more secure default posture.

If you want to be able to access the broker from other machines you will need to explicitly edit the config files to either add a new listener that binds to the external IP address (or 0.0.0.0) or add a bind entry for the default listener.

More details can be found in the 2.0 release notes here




回答2:


I found I had to add, not only bind_address ip_address but also had to set allow_anonymous true before devices could connect successfully to MQTT. Of course I understand that a better option would be to set user and password on each device. But that's a next step after everything actually works in the minimum configuration.




回答3:


You have to run with

mosquitto -c mosquitto.conf

mosquitto.conf, which exists in the folder same with execution file exists (C:\Program Files\mosquitto etc.), have to include following line.

listener 1883 ip_address_of_the_machine(192.168.1.1 etc.)


来源:https://stackoverflow.com/questions/65278648/mosquitto-starting-in-local-only-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!