Publish NaN on MQTT

Andrew,
ues Y2K is th name of my boat where I live.

I tried to change the MQTT IN to Json Object but in the debug I read "Failed to parse JSON string" because it cannot manage the "NaN".

I tried, right now again, with Flespi, my cloud MQTT, and everything works.

Thanks for your time.
Max

Ok, I didn't get as far as the NaN bit...... But I'm a bit confused that it worked as is, but I don't have MQTT installed on the machine it is running.

Not sure if lcoal-host means it just cheats or not.

You can't send the received message into a node that expects a number.

You need to take apart the message to get the numbers.

Though there will now be two messages, as there is Latitude and Longitude.

Andrew, you are missing the point, which is that he publishes one message to mqtt and gets two back, the good one and a NaN.

Sorry. Ok. I am not as quick as I would like, or usually am.

Ok, I'm not fully up to speed with exactly what is happening.

Reading the whole thread again this is what I get:

1 - if you use your local machine as the MQTT broker, it (the MQTT part) sends two messages back in reply to you sending a message.
2 - if you use an external MQTT broker, it works.

Really going out on a limb:

Open the CLI (Terminal) on the Ras pi.
Actually two.....

The topic (channel?) of MQTT you are using is:
vessels/self/navigation/NewPositionTest

In the CLI send a message to yourself.

In one type:
mosquitto_sub -h local-host -t vessels/self/navigation/NewPositionTest

Then in the other CLI type:
mosquitto_pub -h local-host -t vessels/self/navigation/NewPositionTest -m "This is a test"

See if you get two replies.

If not, expand on this and copy/paste the message payload and see what happens from the CLI.

I'm only throwing ideas in an attempt to find out where the problem is happening and why.

Another thing to try:

IF you get back two replies.......

cd .node-red
node-red-stop

and try again.

I am only saying this to eliminate things one at a time and piece by piece.
Otherwise there is not going to be much happening to rule things out as good or bad.

The results from post 13 confirms that when you publish to that topic you are getting two results back. I can only think of two possibilities for how that could happen.

  1. As you have suggested, a serious bug in the mqtt broker that somehow makes that happen. The reason I am resistant to that suggestion is that it would be a very odd bug. It could be that however.
  2. That something else is also subscribed to that topic (or a wildcard version of it) and that when it sees the message from your publish it then publishes the NaN. To fit the fact that when you switch to a different broker it fixes the problem requires that this second client (or flow) does not publish to the different broker. Is that conceivable?
    One way to test that would be to change the topic in your test flow to "something/completely/different" for the publish and the subscribe and see what happens.
1 Like

What happens If you change the topic to something else in both the publish and subscribe nodes?

1 Like

Guys,
yes if I change the topic with something completly different string it works also on local MQTT Server.

That is very good.

Thanks again for your time.
Max

I am still suspicious of the local MQTT server part in all this.

What happens from a terminal/CLI as I suggested?

Andrew,
I think that Mosquitto is not my MQTT server on my installation.
The MQTT Server that I have comes with Openplotter image, so I cannot follow your instruction.

Max

Ok, that's no problem in that sense of things, but it (therefore) is a possible problem.

I have to agree with the line of thinking that:

If you remove all known things that what ever is left - despite what it is - has to be the problem.
(Or words to that end)

I would seriously dig into what it is doing.

Can you understand why I am saying this?

I have no bias to any part of the system. I am simply trying to find the cause by testing parts.

That if you change the topic and it doesn't give the two replies per message is also indicative that there is something going on behind the scenes which could be causing this to happen.

So what happens in the CLI when you type mqtt_sub......?
command not found is probably what I am guessing with your reply.

That too is worrying as there should be some mechanism for MQTT to send messages.
The bare bones is (I'm guessing) that.
If it isn't that means (implies - probably better) that the whole thing (MQTT) has been changed.

Hope to hear back.

Andrew,
I understand your point of view so if I can help you, here I am.
I tried to type some mqqt command, but the answer is: "Commando non trovato" (command not found in Italian)

Let me know how can I help you.
I can try to write in the forum of OpenMarine, who develop OpenPlotter, but I don't know exactly what ask them, or may be you can enter in contact directly at https://forum.openmarine.net/index.php or again I can do it for you if you write me what I have to ask.

Let me know.
Thanks
Max

Ah! It is written in Italian.

I think you need to show them what is happening and get them to explain why you are getting two replies to one message.

Ideally MQTT is only a message handling system. You send a message in and you get it out.

That you send one message in and you get two is alarm bells - for me.

This anomaly needs to be resolved - by them.
Then you can see what happens from there.

Good luck.

But at this point you (we) have established that other than that is working.
If you change the topic to something else it doesn't send back this NaN error.

So when it is set to that topic you get the error.

What is happening really needs to be explained - by them.

Have you got any other flows subscribed to that topic, or possibly a different application, maybe on a different machine, subscribing to it?

from the CLI please enter mosquitto -v and that will tell us the version of mosquitto if it is running on your pi.

Also, could you open one of the mqtt nodes and then show the server you are using.

@spidgrou you have marked the thread as solved, does that mean you have found the underlying problem?

Colin,
No, I've market solved because you found a solution changing the topic, but later Andrew wrote again.
I remove the flag.
Tomorrow morning I will write to the openplotter team.

Max

Hi,
Unfortunately it is not Mosquitto server on my raspberry. I'm using an version call Openplotter that has his mqqt server already installed and it seem that is impossible to send any publish.

Max

Colin
Tomorrow morning I will try, now I'm tired and I need to sleep :sleeping::sleeping::sleeping::sleeping:
Max

Colin,
I've just tried to publish to the same topic "vessels/self/xxx" with a esp8266 with tasmota firmware and i have the same result.

If I publish to the topic "vessels/xxxx" everything works well.
So it seems that only under "xxx/self/" I have a problem, that is the place where all the messages come from SignalK.

What do you think?
Max