TCPClient seems to kill my connection

I’m working on a small project that uses an instance of TCPClient to hit a scenario I’ve set up on PushingBox, but it seems like every time it makes that call, it loses its connection to the internet a few seconds later; i.e., starts flashing cyan, then a seemingly random pattern of red flashes, then attempting to reconnect to my wifi network. I’ll attach a link to a video clip of the pattern in case anyone is curious.

Red error LED pattern

Fortunately, the call seems to always go through, and the core does reconnect itself within a few seconds, so it’s not a huge disruption in how my project should work, but I am curious to know why this is happening. I’ve specifically written my code to make the call to PushingBox a maximum of once every ten seconds, and I’ve been able to verify through some serial debugging messages that it is only attempting a TCP connection once per button press.

My cores are all up to date with the recent deep update. Has anyone else had this problem?


My code in case it helps:

char DEVID1[] = "<MY DEV ID>";
char serverName[] = "";
int waittime = 0;
char rang = 0;
char DEBUG = 1;
TCPClient client;
char lastConnected = false;

void setup() {

void loop() {
    if(!(digitalRead(D1) || rang)){
        rang = 1;
        waittime = millis();
    if(rang && (millis() - waittime >=10000)){
        rang = 0;
    if (!client.connected() && lastConnected) {
    lastConnected = client.connected();

void sendToPushingBox(char devid[]){

  if (client.connect(serverName, 80)) {

   if(DEBUG){Serial.println("sendind request");}
   client.print("GET /pushingbox?devid=");
   client.println(" HTTP/1.1");
   client.print("Host: ");
   client.println("User-Agent: Arduino");
  else {
    if(DEBUG){Serial.println("connection failed");}

Hi @twalsh

The red flashes are SOS N-flashes SOS as described here. Your video never loaded for me so I can say what you have but 1 flash for hard-fault or 8 flashes for out of memory seem likely.

You are leaving the connection open to pushing box for the 10 seconds since you don’t do client.stop() until you come round again, but you never pickup the bytes pushingbox is sending back to you. I would try waiting for a return value to come back via client.available() and then use client.flush().

1 Like

That appears to have done the trick, thanks!

1 Like