TCP Connection in SEMI_AUTOMATIC mode doesn't detect client disconnects

I’m running a basic TCP server on my photon and everything works great while the AP is connected to the internet. When NOT connected to the internet, all works fine except that if the client disconnects, the photon doesn’t notice. I’m checking return codes on client.write() and attempted to send ping commands periodically, but it still doesn’t detect a client disconnect unless the AP is connected to the internet.

Any suggested work-arounds?

Startup code here:

// This #include statement was automatically added by the Particle IDE.
#include "SparkIntervalTimer/SparkIntervalTimer.h"

// Comment this line to connect the device to the cloud.
SYSTEM_MODE(SEMI_AUTOMATIC);


#include "Particle.h"

void sendBroadcast(void);

//CANChannel can(CAN_D1_D2,1024,32);
CANChannel can(CAN_D1_D2);
int led1 = D7; 
TCPServer server = TCPServer(2500);
TCPClient client;
unsigned char inbuf[100];
int connected_flag=0;



String ipStr;
int highlow=0;
int sendPingFlag=0;
int canDetectFlag=0;

#define MAX_MESSAGE_IDS     14
#define SEND_MS             500

unsigned char sendNow=0;
IntervalTimer sendTimer;
//IntervalTimer onlineDetectTimer;
IntervalTimer canDetectTimer;
//IntervalTimer pingTimer;

CANMessage signals[MAX_MESSAGE_IDS]; 


int main()
{
    setup();
    
    while(1)
        {
            loop();
        }
    return 42;
}

void setup() {
    WiFi.on();
    WiFi.connect();

    signals[0].id=0x0D;
    signals[1].id=0x1E;
    signals[2].id=0x1D;
    signals[3].id=0x0A;
    signals[4].id=0x12;
    signals[5].id=0x22;
    signals[6].id=0x25;
    signals[7].id=0x21;
    signals[8].id=0x2f;
    signals[9].id=0x64;
    signals[10].id=0x65;
    signals[11].id=0x23;
    signals[12].id=0x20;
    signals[13].id=0x6ff;
    
    sendTimer.begin(timerCallback, SEND_MS, hmSec);

    pinMode(led1, OUTPUT);
    can.begin(500000); // pick the baud rate for your network
    
    IPAddress myIP = WiFi.localIP();

    
    IPAddress myAddress(192,168,1,189);
    IPAddress netmask(255,255,255,0);
    IPAddress gateway(192,168,1,1);
    IPAddress dns(192,168,1,1);
    //Actually set the static ip
    WiFi.setStaticIP(myAddress, netmask, gateway, dns);
    //Tell the photon to use the static ip 
    WiFi.useStaticIP();

    server.begin();
    
}

....

    if(!client.connected())
    {
        killClient();
    }
    else
    {
        digitalWrite(led1, HIGH);
     }

....

void killClient()
{
    digitalWrite(led1, LOW);
    client.stop();
    client=server.available();
}