Server disconnection when using another mqtt connection

Hello, I have a problem in which I have a panel with Arduino Mega further away from me, and in addition to using remote updating, I would like to use remote system debugging, in which I would use an MQTT connection with nodered as the interface.
The library I use is PubSubClient.h, needing to create the following objects:
‘EthernetClient ETHCliente;’
‘PubSubClient client(ETHCliente);’

To start this communication I use the commands:
‘cliente.setServer(server host, port);’
‘cliente.setCallback(name of the function that will listen to the server);’

When I submit to a topic with the function:
‘cliente.publish(topic, payload);’

The Blynk server disconnects giving me the following message on Serial:

“Heartbeat timeout”

I suspect there is a conflict between communications because I believe that Blynk also uses mqtt communication, how can I get around this?

I’d suggest that you just use MQTT via Node-Red (or MQTT direct to the Blynk server) and don’t run any Blynk code on your device at all.

Pete.

That’s right, I would use nodered as a serial debug only, as I really like blynk’s layout, especially thinking that in nodered I need to program my templates on the dashboard a lot for how much I occupy on my panel, something that I can already do in blynk Okay, I’m going to study how to use the debug itself in blynk through a terminal widget or something similar

None of what you’ve just said makes any sense to me in relation to my previous reply!

Provided that your device is only talking to Blynk via the Blynk IoT contrib or via a direct MQTT connection as described here…

Then you should be fine.

Pete.

Server disconnection when using another mqtt connection

I’m not sure if I get you right, but it is forbidden to use a single device auth-token on a multiple MQTT connections. Source:

Blynk.Cloud currently disallows simultaneous connection of multiple MQTT clients using the same auth token.

Hello, no, there would be 2 different servers, one I use blynk with its normal programming as described in the documentation, and the other mqtt service I use nodered, with its own mqtt broker, with just one topic for sending system debugging Strings, as if it were a Serial.println remotely

I don’t really understand exactly what you’re proposing, as your description seems to change each time.
But, you can’t have two “devices” (servers if that’s what you want to call them) connecting to the Blynk cloud server with the same Blynk auth token at the same time.

As I said earlier…,

Pete.

I think I’m not expressing myself correctly, I have a device, an arduino mega, on this I have a code running that connects to blynk, where I have all the functionalities through the app, but I want to debug the system in case of an error, in this case I would send the messages of what is happening to a nodered broker, as my panel is far from me, if I am personally present, I can debug via its USB using serial communication, but I want to do this remotely, for example: “when the program identifies a low brightness, will call a function that will turn on the lights”. It may be that Blynk will indicate that it happened, but if it doesn’t, I want to be able to know if the function was called correctly, something I can only do with the Arduino Serial, or remotely I would like to send a String to a topic and read it. topic with nodered in a way to debug my program

this way as in the debug on the right with the nodered debug node:

I guess that in theory it is possible to have an ssl/tls connection to the Blynk server as well as an MQTT connection to Node-Red at the same time, but that’s not something I’ve ever tried. I’m not sure what sort of network connectivity you’re using with your Mega, but I would suspect that the library you’re using may also be an issue.
Life tends to be easier if you use a board with native IoT capabilities, like an ESP8266 or ESP32.

My approach is always to have the board talking only to Node-Red, using a regular PubSub client sketch, then Node-Red talking to Blynk via the Blynk IoT contrib.

However, if your device talked directly to Node-Red, and as you say you “don’t like Blynk” then why not do everything in Node-Red.
It’s not difficult to make the Node-Red dashboard accessible from anywhere in the world, and it’s also very easy to connect to your Node-Red flow console if you use something like ZeroTier.

The other alternative is to send your board’s serial output to the Blynk terminal widget, but you’d need a Maker subscription for that.

Pete.