Beginner's problem: No connection to MQTT

Hi,

I'm quite new to node red and just tried to get a MQTT connection running without success. I entered the ip address and username/password and a topic as well. However, after deploying there's no "connected"-indicator below the MQTT node and it doesn't receive any values.

When I enter the same information in MQTT fx, everything works fine.
I tried this with 2 MQTT-servers (running on raspis).
Do you have any ideas what I could try?

Node red version is 1.2.9. Here's some additional info. I don't really know what it means, but it was asked for in a simular topic and might be helpful.

(sorry)

Hang on. I posted too soon.

Could you show a screen shot of you sending a MQTT message from the terminal?

I am not seeing that.

I'm not sure that is going to help you and/or the problem.

What you should be able to do is open a terminal and enter something like:

mosquitto_sub -h (ip address) -t (topic)

Then from another terminal - same machine to start with.

mosquitto_pub -h (ip address) -t (topic) -m (message)

Do you see the message?

I'm not really sure what you mean (all this is still very new to me...) but here's what I did:


Looks like I'm not authorised like this?

Welcome to the forum @Ursusprimus.

Are you using the latest version of node-red (1.2.9)? I think there were some issues with MQTT a little while ago that have been fixed. It may not be the problem here but worth upgrading first just in case.

Yes, I have version 1.2.9

If you are using security stuff, it won't be as simple as I showed you. But I can't say if you are or not.

Search how to send message from the terminal over MQTT and get that part working first.

The answer is kind of there. You do seem to be using keys/security.

So you will have to enter the key as well. I haven't tried that, but it isn't too difficult.

Try this link. Scroll down a bit and look for password/keys

1 Like

It is odd that the status is not showing at all.
If you put the wrong credentials in, or put the wrong server address in, do you see a status shown then?

Stop node red, then start it in a terminal and post the resulting output here, that might tell us something.

I entered: mosquitto_sub -h 192.168.178.25 -t /Test -u openhabian -P mypassword
and then nothing happened (got in the next line, but nothing at the beginning and I couldn't enter any more commands). Then i restarted the terminal. <-- this is probably irrelevant.

However, when I looked in node red again, there suddenly was a connection. And strangely, the connection with mqtt fx was interrupted:

When I reconnected in mqtt fx, the connection got lost in node red ...

So, for some reason it seems to be a little better now. But looks like there's only one connection at a time. Does this give you any clues?

You probably have the same Client ID in the two connections. You must not have two connections with the same client ID as the server assumes the ids are unique and that if a client connects again then the old connection should be dumped (this could happen if the client were roaming for example, so the connection moves from one network to another).
You can leave it blank in node-red and it will make up an id for you.

1 Like

Yes, the Client IDs were identical and now it works.
I still don't now why it didn't connect in the beginning, but if the problem won't appear again, that's fine with me :wink:
Thank you for your quick and very helpful replies!

It might have been a browser caching issue, or something like that. It was not that it wasn't connecting, but that it didn't show any status at all that is unusual and makes me suspect something like that.

The reason that mosquitto_sub would not connect is probably because you did not provide the credentials with it.

this might very well be the case; after all, so far it's running without problems