barnstee / UA-CloudPublisher

A cross-platform OPC UA cloud publisher reference implementation leveraging OPC UA PubSub over MQTT or Kafka. It runs in a Docker container on standard Docker hosts or on Kubernetes and comes with an easy-to-use web user interface.
Other
36 stars 10 forks source link

Connect to a local MQTT Broker #5

Closed delema98 closed 11 months ago

delema98 commented 11 months ago

I would like to connect the UA-CloudPublisher with a locally installed mqtt broker (HiveMQ). Both services run as containers sharing a network with the host.

The broker works. Different mqtt clients can publish and subscribe (without specifying a user / password). The broker can be reached as "localhost" with port 1883.

What settings have to be made so that the UA-Cloud Publisher can connect to the broker? I have tried various configurations, but none have worked so far.

I get the following errors:

ua-cloudpublisher | warn: MQTTClient[0]
ua-cloudpublisher | Disconnected from MQTT broker: UnspecifiedError

or

ua-cloudpublisher | crit: MQTTClient[0]
ua-cloudpublisher | Failed to connect to MQTT broker: The input is not a valid base-64 string because it contains a non-base-64 character, more than two padding characters, or an illegal character in the padding characters.
ua-cloudpublisher | warn: MQTTClient[0]
ua-cloudpublisher | Connection to the MQTT broker was disconnected: UnspecifiedError

If any more information are needed I'm happy to share those!

barnstee commented 11 months ago

Do you have Create Broker SAS Token checked in the configuration page? If you do, uncheck it.

delema98 commented 11 months ago

SAS Token is not checked. I only specified the required fields. No matter what I type into the fields I always get the "Unspecified Error"

warn: MQTTClient[0]
      Disconnected from MQTT broker: UnspecifiedError
crit: MQTTClient[0]
      Failed to connect to MQTT broker: Error while connecting with host 'localhost:8883'.
barnstee commented 11 months ago

Hmm. "unspecified error" comes from the MQTT broker. Perhaps there is something in the HiveMQ logs to figure this out? Also, which fields did you specify exactly and are the others all blank? Perhaps I need to add a different MQTT client config in UA Cloud Publisher if the fields are blank...

delema98 commented 11 months ago

I switched to mosquitto and started the UA Cloud Publisher by building it locally with my IDE. Now it seems to work (Perhaps some docker-compose issues). I'll investigate it further and keep you updated

barnstee commented 11 months ago

OK. Let me know if you find out more from HiveMQ. I have a good relationship with their CEO, so can assist as well if you get blocked. My hunch is that it can't handle an empty username and password string provided...

delema98 commented 11 months ago

Here are my updates: I was able to get my entire setup working, which consists of an opc-ua simulator, an mqtt broker, and the ua-cloud-publisher. Both brokers tested (HiveMQ and mosquitto) are now working. A blank username + blank password was not necessary in either case. What I struggled with was the correct docker setup + missing testing scripts.

One comment: when running / debugging UA Cloud Publisher, the CLI option "USE_KAFKA=False" (also "USE_KAFKA="0") still initializes a Kafka client, as it is only checked if this option is present.

Are you somehow interested in the docker-compose + a short readme of my setup? Maybe it will help others to get things working. If not, I'll just set up my own public repository.

Thanks for your support!

barnstee commented 11 months ago

Yes, please send me your docker compose setup and I'll make it available.

delema98 commented 11 months ago

Sure :) UA_Cloud_Sim_Environment.zip

barnstee commented 11 months ago

Awesome, it's in: https://github.com/barnstee/UA-CloudPublisher/tree/main/TestEnvironment