Edge compute broker config

When enabling the broker in the docker config file, do I have to set port,address,username,password, or are some default values in place?

I get this when trying to publish from a edge workflow:
ValidationError
Failed to publish message, local broker has been disconnected

Hey @Lars_Andersson,

When enabling the local MQTT broker on the Edge Agent, you do need to set Port, Address, Username, and Password.

I get this when trying to publish from a edge workflow:
ValidationError
Failed to publish message, local broker has been disconnected

Is this error related to your first question? Did you set any values for the fields you mentioned above, or did you set values and are now seeing this error? If you could provide any screenshots or any additional context around this error, it would help me a lot!

Thank you,
Heath

I got the same ValidationError before and after entering port info e.t.c in the config file.

Here is the edge workflow:

@Lars_Andersson,

Would you be able to share a screenshot or snippet of the local broker configuration you’re using for your Edge Agent?

Thank you,
Heath

I start it like this: sudo docker run -d --restart always --name docs-agent -v /var/lib/losant-edge-agent/data:/data -v /var/lib/losant-edge-agent/config.toml:/etc/losant/losant-edge-agent-config.toml -p 8080:8080 losant/edge-agent losant/edge-agent

@Lars_Andersson,

Thanks so much for the extra info!

If you run docker logs <container-id> where the container-id is the ID of the container running the Edge Agent, do you see a message that looks similar to the following?:

2020-10-02T17:57:46.186Z [error] Local broker: listen EADDRNOTAVAIL: address not available 192.168.86.59:1883

I would suggest enabling the address for the local broker on 127.0.0.1, and including -p 1883:1883 in the Edge Agent start command since this is the port that you are configuring the broker to be run on.

Thank you,
Heath

I switched the IP to 127.0.0.1.
Now it works from a losant workflow node.

Then I tried publishing from an external mqtt client and it would not work, so I added the 1883 port to the start command, but I can still not get it to work from an external client.

also, the “docker logs” command show no output.

@Lars_Andersson,

Is the machine you’re using the external MQTT Client on the same network as the Edge Agent? In the config.toml file, where you set the IP to 127.0.0.1, did you also include a username and password? Are you using that username and password in the connection with the external MQTT client?

also, the “docker logs” command shows no output.

In that same config.toml file, do you have:

[logger]
out = '/data/losant-edge-agent-log.log'
level = 'verbose'

or something similar? If this is not configured in your config.toml file, then Docker is not managing logs and putting them in the configured file.

Thank you,
Heath

Yes to all questions above

@Lars_Andersson,

Does the external MQTT client connect, and only messages are unable to send? Would you be able to share a picture of your external MQTT client connection configuration?

Thank you,
Heath

No it does not even connect.
I’m using MQTT.fx and here are some settings:


image
image

I did a “lsof” command on the docker host. does this look correct?
image

@Lars_Andersson,

Just to take a few steps back so I can have a clearer idea of what you’re hoping to accomplish and the issue you’re facing.

You have a gateway running the Losant Edge Agent with the local MQTT broker enabled and are hoping to connect to that local broker from a machine/device that is on the same network as the gateway. You are testing this connection and setup with MQTT.fx (the external MQTT client). Do I understand this correctly?

Have you seen any errors in your attempts to accomplish this?

Thank you,
Heath

That is correct.
All info I’m getting from the MQTT client is that it can’t connect to the broker I have defined.
So I would think it has to be something IP or protocol related.

Any further suggestions? I’m not sure what to try next.
Why would the “docker logs” command not produce an output when I have logging enabled?

Hey @Lars_Andersson,

I spent some time yesterday and this morning digging into this. Here’s what I have for you…

In my tests, I have a Raspberry Pi running the Edge Agent with the local broker enabled. I did not set a username or password, or an address. I simply added

[localBroker]
enabled = true

to my config.toml. Then, with my laptop, I was able to connect to the local broker by using the IP address of the host machine. So, my Raspberry Pi’s IP address at the time was 192.168.0.175, so when connecting to the local broker, I used mqtt://192.168.0.175:1883 since 1883 was the port I set in the docker run command for the MQTT broker.

Although the local broker does require a Client ID, you can use a string. Unlike Losant’s Cloud Broker where the Client ID must be a Device ID, at this level, the Client ID just needs to be a string.

Why would the “docker logs” command not produce an output when I have logging enabled?

The docker logs command does not work in this case because you have logger configured in your config.toml file. When you have logger configured, the logs are written to a file, in your case losant-edge-agent-log.log. You would need to read that file to see the logs.

Let me know if any of this helps you, or if you need more clarification.

Thank you,
Heath