Mosquitto MQTT Broker Issue

Hi ,

while i am trying to do below command i am followings error. How can i resolve this

sudo tedge connect c8y

Some more details would be useful here, as there could be a number of reasons why mosquitto is failing to run.

Can you please provide the following information?

  • Which mosquitto version are you using, check by running mosquitto -h
  • What are the contents of your mosquitto config file? cat /etc/mosquitto/mosquitto.conf
  • What files do you have under /etc/tedge/mosquitto-conf? e.g. ls -l /etc/tedge/mosquitto-conf/
  • How did you install thin-edge.io? Did you install it via our install script (e.g. wget -O - thin-edge.io/install.sh | sh -s)

However to debug mosquitto it might be more helpful if you try running the mosquitto command manually, and then view what the output is. Assuming that the mosquitto service is stopped, you can then run mosquitto locally using:

sudo mosquitto -c /etc/mosquitto/mosquitto.conf

Then observe the output to see what is going on.

Please find details as below

Which mosquitto version are you using, check by running mosquitto -h (2.0.11)
What are the contents of your mosquitto config file? cat /etc/mosquitto/mosquitto.conf (No Such Directory)
What files do you have under /etc/tedge/mosquitto-conf? e.g. ls -l /etc/tedge/mosquitto-conf/ ((No Such Directory))
How did you install thin-edge.io? Did you install it via our install- script (e.g. wget -O - thin-edge.io/install.sh | sh -s)

Installed via “curl -fsSL https://thin-edge.io/install.sh | sh -s”

sudo mosquitto -c /etc/mosquitto/mosquitto.conf

image

while trying below command i got fallowing error

**sudo mosquitto -c /etc/mosquitto/mosquitto.conf**

Please read the instructions carefully and use copy/paste rather than typing the commands, as you’ve mixed up a lot of the commands, and it is a bit unclear what the current state is.

But generally google is also a good source of information to help debug mosquitto, here is a result that I found regarding the “Couldn’t open database”. Broker corrupts persistent database mosquitto.db · Issue #424 · eclipse/mosquitto · GitHub

So you must have some invalid mosquitto configuration for whatever reason. Try to simplify your setup:

  1. Edit the mosquitto.conf file under /etc/mosquitto/mosquitto.conf and add the following contents (please paste exactly as it is)

    log_dest stdout
    include_dir /etc/tedge/mosquitto-conf
    include_dir /etc/mosquitto/conf.d
    
  2. Save the file, and exit the editor

  3. Try starting mosquitto manually on the command line

    sudo mosquitto -c /etc/mosquitto/mosquitto.conf
    

    Review the output and post it in a code block in a comment. Note: A code block can be created using 3 back tick characters, e.g.

    ```
    example code block
    ```
    

Please find the log details

It looks like you have something else running which is using port 1883 (most likely another instance of mosquitto running). Either the mosquitto service is running again, or you started another background instance of mosquitto via another shell.

You can check if the mosquitto (systemd) service is running

sudo systemctl status mosquitto

And if it output shows that the service is running, then maybe you don’t have a problem anymore, and then we can end the debugging. And if the service is showing it is not running, then you can just reboot your device to try to kill the extract unexpected process which is using port 1883 (if you don’t know how to use standard linux tools such as pgrep and kill).

Otherwise, if the problem still persists, maybe you’re running into the mosquitto bug where the mosquitto service is starting before the network has been established. Though see the mosquitto project for further details: Mosquitto may fail to start on boot · Issue #2878 · eclipse/mosquitto · GitHub