Connects subscriptions in Websocket agent

Hi all and happy Sunday.

I am new with Openremote and i dont know how to use Websocket Agent. We have right now all device connecting over MQTT to our EMQX Broker. Now i Enabled on Emqx the websocket. Over the MQTT Explorer i can connect without problem.

ws://111.11.111.111:8083/mqtt
user: user
Password: password

Before to use MQTT Service on OpenRemote i like to test over Websocket but i dont have any ide how to connect to my Websocket.
I create a websocket Agent

connectURL ws://111.11.111.111:8083/mqtt status: connected

But now how to use credential and subscrition. Can some help me on this and provide my a code how to connect.

Thank you in advance
Salva

Hi,
Try adding the attribute “Username password”. Create the attributes to get the data, add them the agent link, add message match predicate and the subscription.
e.g.:

Hi perrochiba thank you for your help,

I made what you mention but something still I’m doing wrong. See print screen

Thanks in advance
Salva

Let’s take a step back.

What is it you’re trying to achieve?

From your initial comment it sounds like you’re trying to connect OpenRemote to another MQTT broker over websocket?

If so this isn’t supported and generally MQTT over websockets is to allow Web browsers to act as an MQTT client.

There is a simple MQTT agent in OpenRemote which will give you an MQTT client to connect to another broker.

Hi Rich

Thank you for your advise. This is exactly what i am looking for. I was not ever that with Openremote you can connect with external MQTT Broker.

Rich I mention on my email i am new on Openremote. If i like to connect over an MQTT agent to external Broker how i do this if my Broker have credentials (User:Password) to connect.

Kind regards
Salva

1 Like

You should be able to add the optional Username Password attribute which takes a JSON object:

{
  "username": "myuser",
  "password": "mypassword"
}
1 Like

Hi Rich

I think I need to understand how Openremote works. What I need if i like to connect to External MQTT Broker.

  1. MQTT Agent for connecting to a External MQTT broke

and where i can add the credential
{
“username”: “myuser”,
“password”: “mypassword”
}

This is me problematic i need to understand the flow of Openremote. Any advice on this.

Thank for your time
Salva

Configuration of agents is done via the attributes of the agent; to add a username and password to an MQTT agent you need modify your agent in the asset viewer to add the well known attribute called Username password:

  1. Click modify in the top right (if you’re already in edit mode then you will already see the save/view buttons)
  2. Click Add attribute
  3. Select Username password from the list

Hi Rich

Thank you for your help now i am connected and receiving data from external MQTT Broker.

What i see Openremote is fit for our Business. Is absolute powerful.

Thank very much
Salva

Hi Rich.

Thanks for the explanation.

I’m trying to use my username and password, but the agent status remains stuck on “waiting” and I can’t connect. I’m using an external broker (EMQX running in a Docker container on my computer).


(Note: I’m using port 1884 because port 1883 is already in use on my computer
Note 2: I’ve already set the username and password permissions on my broker, and I can successfully connect using MQTTX and MQTT Explorer with these credentials).

Any advice or recommendation?

Thanks for your time!

Hi Jose,

Did you get your MQTT agent connection working in the end?

Hey Rich! Sorry for not getting back to you sooner.
YES! I managed to connect to the broker using the username and password, thank you so much!
Honestly, I don’t understand what the problem was, since I didn’t change anything — it just worked on one of my attempts, and luckily I haven’t had that issue again.
Thanks again!