Wifi Shield WLS06201 is always in unstable TCP connection

Wifi Shield WLS06201P is always in a unstable TCP connection.
when it run the code in the beginning , it can connect the server and send data correctly.
But after 3-5 hours, it con not connect the server, it return “Bad Address” . Then, I shutdown the power and restart, but it still can’t connect the server untill I change the internet IP of router .

My code :

#include “Wifly.h”
#include <SoftwareSerial.h>
WiflyClass Wifly(2,3);

#define HTTP_POST_HEADERS “U-ApiKey: a6db4904d575e9ceb9a592a23f50\r\n”
unsigned long start_millis = 0;
char post_data_buf[32];

void setup()
{
Serial.begin(9600);//use the hardware serial to communicate with the PC
Wifly.init();//Initialize the wifishield
Wifly.setConfig(“NETGEAR”,“1234567”); //here to set the ssid and password of the Router
Wifly.join(“NETGEAR”);
Wifly.checkAssociated();
}

void loop()
{
if ((millis() - start_millis) < 20000)
{
return;
}
else
{
start_millis = millis();
}

Serial.println("\r\n\r\nTry to post data to url");
Serial.println("-------------------------------");
snprintf(post_data_buf, sizeof(post_data_buf), “{“value”:%d}\r\n”,20);

while(!Wifly.connect(“42.96.164.52”,“80”)); //connect the remote service
.
.(short connecttion)
.
.
Wifly.writeToSocket(post_data_buf);
}

That is weird.

Try

void setup()
{
    ...
    wifly.sendCommand("set i h 42.96.164.52\r", "OK"); // set remote host ip address
    wifly.sendCommand("set i r 80\r", "OK");         // set remote host port
    ...
}


void loop()
{
    ...
    while(!Wifly.connect());   // connect the remote service using pre-set ip and port
    ...
}