Sending UDP mesages- working on Photon but not Electron

I’m trying to send a UDP message to a nodejs server that I wrote. I am not expecting the server to send a reply back.

This is working on my Photon but not my Electron.

Top of my .ino:

UDP Udp;
IPAddress remoteIP(54, 149, 36, 255);
int port = 9000;

and inside my loop:

                String udpString = String::format("B%.1f", fuel.getSoC());
            	int str_len = udpString.length() + 1; 
                char buffer[str_len];
                udpString.toCharArray(buffer, str_len);
                if (Udp.sendPacket(buffer, sizeof(buffer), remoteIP, port) < 0) {
                    Particle.publish("Error");
                }             

My electron is publishing “Error”.

Any ideas? The IP address / port is public & open to the world (go ahead and try it :)). My Photon can publish to it no problem.

Where are you calling Udp.begin()?

Are you using SYSTEM_THREAD(ENABLED)?

You need to call Udp.begin() after Cellular.ready() returns true. In the default automatic with system thread disabled, setup() is fine. However, if you are using SEMI_AUTOMATIC or MANUAL or are using threading, you’ll need to add additional checks.

Aah - I just realized that in my Electron code, I wasn’t calling Udp.begin() at all!

Will confirm tonight but I’m sure that will fix it. Thank you!