Tian stops working after some hours

Your code snippet is not independent enough from the rest of your code to analyse it but, if you suspect that particular piece is the problem, then what you can do is modify your code so to see if the problem changes or goes away:

void CiaoReadWrite1()
{
if (!data.isEmpty())
{

// dummy is a globally defined Sting which has a plausible set of values so the remainder of your
// code still works.
Ciao.writeResponse("restserver",id, dummy );
request++;
}
}

I guess you are using an ESP8266 based Arduino Uno WiFi Edit: see post #9.
Since the Ciao.writeResponse() method uses Strings, you are stuck with these. If, however, these are the problem, you could possibly restructure your code to make less intensive use of them.