Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't load mosquitto.conf #1114

Open
vinistoisr opened this issue Jan 22, 2019 · 4 comments
Open

Can't load mosquitto.conf #1114

vinistoisr opened this issue Jan 22, 2019 · 4 comments

Comments

@vinistoisr
Copy link

Trying to start 1.5 on docker on centos 7.

I created 3 dirs:

/srv/mqtt/log
/srv/mqtt/config
/srv/mqtt/data

create a mosquitto.conf as follows:

persistence true
persistence_file mosquitto.db
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log

put config file into /srv/mqtt/config/mosquitto.conf (permissions 777 owner:group 1883:1883)

start:
sudo docker run -it -p 1883:1883 -p 9001:9001 -v /srv/mqtt/config/mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto:latest

I get: Error found at /mosquitto/config/mosquitto.conf:0.
Error: Unable to open configuration file.

not sure where to go from here. I tried setting owner to root, tried the example mosquitto.conf, tried it all, it just won't accept any .conf, always error on line 0

@ralight
Copy link
Contributor

ralight commented Jan 23, 2019

Sorry for the slightly confusing text below. Reading a config file follows these steps.

  1. If -c is given on the command line, config__read(...) is called
  2. Inside config__read(...), config__read_file(...) is called.
  3. Inside config__read_file(...), if the config file can't be opened, the message Error: Unable to open config file <file name> is printed, then an error is returned.
  4. Inside config__read_file(...), if a memory allocation fails, the message Error: Out of memory. is printed and an error is returned.
  5. Inside config__read_file(...), config__read_file_core(...) is called.
  6. Inside config__read_file_core(), it first attempts to read a line. If this fails, it returns success. If reading the line succeeds, the very first thing that is done is that the line number is increased from 0 to 1.
  7. Once config__read_file_core() returns, its return code is returned by config__read_file().
  8. If config_read_file() returns an error, then config__read() will print the message Error found at <file name>:<line> and then returns an error.
  9. If config__read() returns an error, the message Error: Unable to open the configuration file. is printed, and ultimately the broker exits.

You are getting the messages Error found at <file name>:<line> and Error: Unable to open configuration file.. That suggests that points 3 and 4 above succeed, because those error messages don't appear. Point 6 above is the troublesome one. Either it returns success (which would not produce an error) or it increments the line number and will then either fail or succeed whilst reading the rest of the file. If it does fail, the the line number will not be zero, which it is in your case. Neither of the two possible outcomes matches what you have. Are you certain that there are no other error messages?

@grantwparks
Copy link

That's definitely the error. I get it. Weird thing is, I've been running this same container with this same command many times over the past month, but this crops up once in a while.

docker run -it -p 8883:8883 -p 9001:9001 \

    --name mqtt-broker \
    -v $PWD/mqtt-broker/config:/mosquitto/config \
    -v $PWD/mqtt-broker/data:/mosquitto/data \
    -v $PWD/mqtt-broker/log:/mosquitto/log \
    eclipse-mosquitto

Error: Unable to open config file /mosquitto/config/mosquitto.conf

Error found at /mosquitto/config/mosquitto.conf:0.
Error: Unable to open configuration file.

@orozcohsu
Copy link

I got the same error message
Error: Unable to open config file /mosquitto/config/mosquitto.conf.

@ivdimitro
Copy link

It is enough to create an empty file mosquitto.conf and the error will disappear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants