Random abort when 2 projects are running Node-Red

I have two different Pi-Pico W projects I'm working on. One is a PID Incubator for hatching bird eggs, the other is an infinite repeat cycle timer to control a fogging device in a mushroom grow chamber. The Incubator seemed to be quite solid and ran for a week+ running on its own and not connected to Thonny. Once I started working on the cycle timer it started aborting randomly. I tried to plug it into my windows computer and run 2 instances of Thonny so I could monitor the incubator and continue to develop the cycle timer. I can connect to both Pi Pico W's with USB, but if I run both programs the incubator aborts almost immediately with an strange OS error. Thonny is running on Window11 as is Node-Red

Anyone have any insights?

Do both of these devices use MQTT? Have they got different client IDs?
What error message[s] do you get?

They are both using the same client ID but different feeds. I don't know what the error is as I haven't figured out how to log the error message when it runs stand-alone.

Before anything else, always use different client ID's when using MQTT

1 Like

I had exactly the same issue with a couple of my nodes. If I ran either node on its own it was perfectly fine, but when I introduced a second one, the first one failed immediately. What added to the problem was one node was in my house in the UK and the other in my friend's house in Boston, USA. So I suppose you could say I was performing remote diagnostics at the extreme.

I spent nearly a whole morning painstakingly going through a very long Micro-Python script trying to find a bug (which didn't exist). It was a "slap head" situation when I eventually "twigged" what was going on.

I'd lay money :moneybag: that the responses from @krambriw and @jbudd prove to be your solution.

When I tried to set up a second client ID it blew up my first one and now neither project works. I'll take that as a hint that I need to set up Mosquito as my next step.

Thanks guys. School of hard knocks and all.

You just need to make sure the text in MQTT_CLIENT_ID is unique for each project.

# Connect to MQTT broker
def connect_to_mqtt():
    client = MQTTClient(MQTT_CLIENT_ID, MQTT_BROKER, port=MQTT_PORT, user=MQTT_USERNAME, password=MQTT_PASSWORD)
    client.set_callback(mqtt_callback)
    client.connect()
    client.subscribe(MQTT_TOPIC_SUBSCRIBE)
    print("Connected to MQTT broker")

    return client

I'm having trouble getting mosquito set up, so I fixed hiveMQ. Re
did the feeds to be sure each project went through its own client id and user. Triple checked each flow has its own server, login and password. Its seems to be working now. Thanks again @dynamicdave

Now to try and get mosquitto to work...