Help!? UDP send in LogHandler hangs electron w/ 0.6.1

Hi peeps, I’m trying to create a LogHandler that ships data out UDP, similar to the PaperTrail loghandler at https://github.com/barakwei/ParticlePapertrail. (note – their example also hangs for me)

I can normally send UDP just fine, but if my class extends the LogHandler class, it hangs when I send. I whipped up a tiny example to illustrate.

I’m using an electron with 0.6.1, and can see in logs that it’s booting successfully, connecting to cloud, etc. Anyone have any ideas? Thanks! - Henry

This works fine

This hangs
The LogHandler doesn’t actually try to send UDP until (millis() > 10000) so you can watch it work briefly, then hang on the first UDP send.

I have the same issue. I can send UDP logging messages if I simply inline the networking code in my loop or application code. As soon as I put the exact same code into a LogHandler, the network calls (e.g. Cellular.resolve() or UDP.begin()) lock up the device. Waiting for Cellular.ready() and Particle.connected() makes no difference. I am running in SYSTEM_THREAD(ENABLED) FWIW.

Very frustrating.

Hello @hgoldwire @ruzdic Firmware 0.8.0-rc.3 Pre-release is out on the Web IDE for Core/Photon/P1/Electron. This release fixes the issue seen above where recursive logging would lock up the application thread on the Electron. It’s still not advisable to log too much over UDP on the Electron. I’ll suggest two that work well below. Please see the release notes on the Particle Firmware Updates Thread

// app level over papertrail
PapertrailLogHandler papertrailLogHandler1(PAPERTRAIL_HOSTNAME, PAPERTRAIL_PORT, "MyAppName", System.deviceID(),
    LOG_LEVEL_NONE, {
    { "app", LOG_LEVEL_ALL }
    // TOO MUCH!!! { "system", LOG_LEVEL_ALL },
    // TOO MUCH!!! { "comm", LOG_LEVEL_ALL }
});

// system info and app level over papertrail
PapertrailLogHandler papertrailLogHandler2(PAPERTRAIL_HOSTNAME, PAPERTRAIL_PORT, "MyAppName", System.deviceID(),
    LOG_LEVEL_NONE, {
    { "app", LOG_LEVEL_ALL },
    { "system", LOG_LEVEL_INFO }
    // MAYBE { "comm", LOG_LEVEL_INFO }
});
1 Like