ESP8266 Send/Receive stops working?

I swear I had this working at one point. But, recently, I pulled up my old sketches and flashed them to my NodeMCU 0.9's and now they no longer work. Hoping someone with some experience with ESP8266's can give me some guidance.

All I'm trying to do is send a single word (String) from one ESP8266 to the other once every few seconds. The sequence is supposed to go like this:

ESP8266 #1 comes online, configured in STA+AP
ESP8266 #2 comes online, configured in STA, connects to ESP8266 #1's AP
ESP8266 #1 sends ESP8266 #2 a message ('status/r'). ESP8266 #2 responds ('active/r').
ESP8266 #1 sends a message every couple of seconds to ESP8266 #2. ESP8266 #2 writes to serial what it receives.

That's it! But, for some reason, this procedure works all the way until the end, then stops working. ESP8266 #2 will receive the first couple of Strings from #1, then it just stop receiving them. It's like it gives 10 good seconds of connectivity, then it just drops out.

I can tell on the serial monitor of ESP8266 #1 that the connection has dropped (or that ESP8266 #2 has stopped listening) because while I only have a 1 second delay programmed in, it will take several seconds between communication attempts. That appears to be because the command (client.println(String)) has to time all the way out before it tries again.

How can I keep ESP8266 #1 and ESP8266 #2 connected in perpetuity? Am I running afoul of some limit I'm not aware of, or do I have to re-insatiate the connection on each pass of the loop or something?

This obviously isn't the real code, but here's a dumbed down example of what the code is approximately like for reference.

ESP8266 #1:

WiFiClient client
void setup {
WiFi.mode(WIFI_AP_STA);
WiFi.softAPConfig(ap, ap, IPAddress(255, 255, 255, 0));
WiFi.softAP(ssid);
client.connect(targetIP, 80);
}
void loop {
client.println('string1/r');
delay(1000);
client.println('string2/r');
delay(1000);
client.println('string3/r');
}

ESP8266 #2:

WiFiServer server(80);
void setup {
WiFi.mode(WIFI_STA)
WiFi.begin(ssid);
server.begin();
}
void loop {
WiFiClient client = server.available();
if (client) {
if (client.connected) {
for (int i=1; i>0; i++) {
String message = client.readStringUntil('\r');
Serial.println(message);
}
}
}
}

I'm going to post this in networking since I'm not getting a lot of attention in Project Guidance. Is there a way to delete this thread here?

this is an endless loop

for (int i=1; i>0; i++) {
  String message = client.readStringUntil('\r');
  Serial.println(message);
}

the watchdog restarts the esp if the loop() hangs

Juraj:
the watchdog restarts the esp if the loop() hangs

To stop that from happening OP should add a yield() to the loop.

It's also not an infinite loop. After 2147483647 iterations the int overflows and goes negative, and the loop breaks. Had OP declared it as unsigned it'd have take a little longer but still not infinite.

wvmarle:
To stop that from happening OP should add a yield() to the loop.

I know about yield(), but is it what you would recommend to make this sketch right?

Instead of the for loop use something like while (client.available())