Is there a known issue with Cores becoming unresponsive where they don’t have the ‘Cyan flash of death’?
It seems like the more I try and use TcpClient the quicker my core will get into a state where it’s dead but the led doesn’t flash: it still has the slow fade in/out blue that it has when it’s normally connected.
I have it set to post a short HTTP GET every 10 seconds to dweet.io, taking great care never to block the loop() for too long, so as not to upset the cloud heartbeat. I see that after a few minutes (a different amount each time) it just stops sending those HTTP GETs, and if I try and query a variable from the core I get back:
{
"error": "Timed out.”
}
All I can do at this point is reset it.
Basically, the core is unusable for me for sending even small amounts of data out.
Contrast this to my other core, which is being queried once an hour: it stays up for a week or so at a time without becoming unresponsive.
I built at 5cc4b6b9f058365cc762f84fdae021052aedae06 and installed it, but now it’s not running my ‘sketch’. If I flash the sketch via the Web IDE it will leave the core firmware alone, right?
Make sure you’re cleaning up your sockets after you post data, I think it’s still possible right now to open too many sockets without closing them properly, and this can kill your sketch. Any chance you can share your code that is crashing?
I’m keeping a socket open and using HTTP 1/1, but I see the same if after .available() returns yes I do a flush() then stop(), and then a subsequent connect() next time around.
Here’s the loop:
void loop()
{
dweetConnected = dweetClient.connected();
if (dweetEnabled && !dweetConnected) {
if (dweetClient.connect(DWEET_ADDRESS, 80)) {
ringBuffer.log("Conn.");
} else {
ringBuffer.log("ConnFail.");
}
}
if (dweetConnected && dweetClient.available()) {
// just read on this loop, so we read as fast as possible
//ringBuffer.log(dweetClient.read());
dweetClient.flush();
//dweetClient.stop();
//ringBuffer.log("Disc.");
} else {
const unsigned long now = millis();
since = now - lastSendTime;
const bool updateIsDue = since > DWEET_EVERY_MS; // This is 10,000
if (dweetClient.connected() && updateIsDue) {
lastSendTime = now;
ringBuffer.log("Send.");
dweetClient.print("GET /dweet/for/foo?temperature=");
dweetClient.print(tempString);
dweetClient.println(" HTTP/1.1");
dweetClient.println();
dweetClient.println();
} else {
update(); // This would go do 1-wire stuff but that’s a NOP right now for testing this HTTP stuff
}
}
}
It looks like maybe you could do the millis / lastSendTime check before you connect the socket? Otherwise you’re just making their server keep a socket open for 10 seconds, which may time out.
The flush will block which could lead me to get killed by the 10s heartbeat.
The stop will disconnect, which means I’ll just need to reconnect next time. Why spend all that time on TCP socket establishment every time? (And even if I do it still hangs.)
If you don’t think blocking is an issue I can try it.