phoddie / node-red-mcu

Node-RED for microcontrollers
124 stars 18 forks source link

MQTT-Out node does not show status "connected" #104

Closed bartbutenaers closed 1 year ago

bartbutenaers commented 1 year ago

Hi @phoddie,

When I add an MQTT-Out node in a standard Node-RED flow, the node will show status "connected" as soon as the node has managed to connect to the specified MQTT broker:

image

However when I deploy the same flow - using Ralph's sidebar - to my wt32-eth01 device, then NO STATUS is being displayed below the MQTT-Out node (although the mcu is sending messages to my MQTT broker at that moment):

image

It would be nice if this could be added, similar to like the following status is already being displayed inside my wt32-eth01 flow:

image

Although while writing this, I start doubting whether this needs to be fixed in this repo or in the sidebar repo from @ralphwetzel.
I mean that I am not sure anymore now whether the status updates are the responsibility of Ralph's proxy perhaps?

Thanks!! Bart

phoddie commented 1 year ago

Hey, @bartbutenaers – that's clear now. Thank you.

I will check that the MCU runtime is sending the status messages (I see the code to do this behavior is present, but I'll step through it and check the output to be sure it is working as expected).

phoddie commented 1 year ago

@bartbutenaers – I used a simple test flow with an MQTT-Out node with id 6a2d91009192a70e. It appears to be sending status messages back through the usual channel. The plug-in can receive these and forward them to the Node-RED Editor.

image

Perhaps there's something unexpected about the messages?

bartbutenaers commented 1 year ago

That was fast...

Hmm that is why I wrote above that I was not sure whether it was a problem in your repo or in my sidebar. So I "assume" that those status updates follow the same route via the sidebar Proxy to my flow editor, similar to the Debug messages. But not sure about that... Perhaps I forget to start something in the sidebar, so the Status updates don't arrive in my flow editor.

I mean somewhere in this part of my cheat sheet:

image

Hopefully @ralphwetzel can illuminate me.

phoddie commented 1 year ago

@bartbutenaers – I don't believe you should need to do anything special to allow the status messages to propagate through. The message trace shown in the my image above should be exactly what is received by the MCU plugin's proxy. Let's see what @ralphwetzel uncovers.

As an aside – it took me a while to understand the status mechanism in Node-RED. It is used both for debugging in the Node-RED Editor and for receiving signals by nodes. Like many things in Node-RED, they are obvious/intuitive to experienced users but really not to someone seeing them the first time. The messages are formatted more for the debugging purpose, so I imagine that was their initial use. Anyway... as I've understood it better, I've also gotten more consistent about implementing support for them in the MCU implementation of nodes. For example, the MCU sensor nodes shows Connected or Disconnected status for sensors based on whether the node was able to connect to the sensor hardware.

bartbutenaers commented 1 year ago

@phoddie, Don't want to go too much off-topic, because off course this is an issue and not a discussion about statusses in general ;-)

However after all the nodes I have developed, there are still things about statusses that I keep doubting about during developing:

So there is not really one single way to go. And every node developer has its own way of working, which makes it sometimes a bit hard to quickly interpret a flow based on the statusses....

But I will stop now about it ;-)

phoddie commented 1 year ago

So there is not really one single way to go. And every node developer has its own way of working, which makes it sometimes a bit hard to quickly interpret a flow based on the statusses....

Understood. That's kind of reassuring. My preference is not to invent yet another style, which is why I'm trying to discern patterns in the existing implementations.

But I will stop now about it ;-)

Me too! (Seems like a good topic for a presentation or a discussion)

ralphwetzel commented 1 year ago

However when I deploy the same flow - using Ralph's sidebar - to my wt32-eth01 device, then NO STATUS is being displayed below the MQTT-Out node (although the mcu is sending messages to my MQTT broker at that moment):

image

Hi @bartbutenaers Sorry - I can't confirm what you report. Are you sure, the MCU was (logically) connected to the editor? As you're using xsbug-log: You can confirm this if you see the debug messages coming in as <info> data in the console monitor.

bartbutenaers commented 1 year ago

Morning @ralphwetzel, Sorry for the delay, I have a severe lack of free time lately due to circumstances...

Well I have to admit that it is not easy to test this in "very" limited time, because I constantly get that other error "address already in use :::5004". So I will first need to try to digest that other discussion this evening. I should have some more time to digg into the technical details, because at the moment I am bit lost with this...

phoddie commented 1 year ago

The root cause here appears to be that the -x option was temporarily disabled in mcconfig. That was resolved yesterday in Moddable-OpenSource/moddable#1072.