Loop stops after 10-15 minutes

I have customized the examplecode regarding to RestClinet, API. I am satisfied that i made it work with my Home Assistant, but... It only works for a while.

This is the latest output before it stops responding. No error code or error message:

TESTstatus RESULT: ok (200)
Respons: {"attributes": {"friendly_name": "Temperature", "icon": "mdi:thermometer", "max": 30.0, "min": 16.0, "mode": "slider", "step": 1.0}, "entity_id": "input_number.ac_temp", "last_changed": "2018-09-01T10:21:26.870616+00:00", "last_updated": "2018-09-01T10:21:26.870616+00:00", "state": "20.0"}
Lengde: 291
Verdi: 20

And this is my code. Please, can you se why it stops? PS: I use ESP8266.

/* RestClient full test suite
 */

//#include <Ethernet.h>
#include <ESP8266WiFi.h>
// #include <SPI.h>
#include "RestClient.h"
#include <ArduinoJson.h> // ROAR


//Legger til Wifi
IPAddress ip(192, 168, 1, 27);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress DNS(192, 168, 1, 1);
const char* ssid     = "Hjemme";
const char* password = "SecretStuff";

void wifi_init(){
  WiFi.config(ip, gateway, subnet, DNS);
  delay(100);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println();
  Serial.print("Connecting");
  while (WiFi.status() != WL_CONNECTED) {
      Serial.print(".");
      delay(200);
  }
  Serial.println();
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Fail connecting");
    delay(5000);
    ESP.restart();
  }
  Serial.print("   OK  ");
  Serial.print("Module IP: ");
  Serial.println(WiFi.localIP());
}

int test_delay = 1000; //so we don't spam the API
boolean describe_tests = true;
RestClient client = RestClient("hassio",8123);

//RestClient client = RestClient("arduino-http-lib-test.herokuapp.com");
//RestClient client  = RestClient("10.0.1.47",5000);


//Setup
void setup() {
  Serial.begin(9600);
  // Connect via DHCP
  Serial.println("connect to network");
  wifi_init();
/*
  //Can still fall back to manual config:
  byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  //the IP address for the shield:
  byte ip[] = { 192, 168, 2, 11 };
  Ethernet.begin(mac,ip);
*/
  Serial.println("Setup!");
}

void test_status(int statusCode){
   delay(test_delay);
   if(statusCode == 200){
    Serial.print("TESTstatus RESULT: ok (");
    Serial.print(statusCode);
    Serial.println(")");
   }else{
    Serial.print("TESTstatus RESULT: fail (");
    Serial.print(statusCode);
    Serial.println(")");
    int teller = 0;
   }
}

String response;
void test_response(){
  //Serial.println(response);
  if(response == "OK"){
   Serial.println("TESTrespons RESULT: ok (response body)");
  }else{
   Serial.println("TESTrespons RESULT: fail (response body = " + response + ")");
  }
  response = "";
}

void describe(char * description){
  if(describe_tests) Serial.println(description);
}

//reusable test variables

void GET_tests(){
//  describe("Test GET with path and header and response");
  client.setHeader( "x-ha-access: SecretStuff" );
  test_status(client.get("/api/states/input_number.ac_temp", &response));
  Serial.println("Respons: " + response);
  
  int response_len = response.length();
  response_len = response_len + 1;
  Serial.print("Lengde: ");
  Serial.println(response_len);
  char json[response_len];
  response.toCharArray(json,response_len); 
  
  StaticJsonBuffer<200> jsonBuffer;
  
  JsonObject& root = jsonBuffer.parseObject(json);
   //const char* sensor = root["input_number.ac_temp"];
   long verdi          = root["state"];
   Serial.print("Verdi: ");
   Serial.println(verdi);
   Serial.println(teller);
   teller = teller + 1;
  
  response = ""; //Denne er viktig for aa unngaa soft wdt reset

  delay(2000);

}

void loop(){

  GET_tests();
}

Making these pointers...

const char* ssid     = "Hjemme";
const char* password = "SecretStuff";

...is a waste of memory and does not accurately reflect their use.

A better choice...

const char ssid[]     = "Hjemme";
const char password[] = "SecretStuff";

Roarnyg:
And this is my code.

Eyeballs and a brain are all that are needed to know the code you posted will not compile. I suggest you start with getting your code to compile.

What is the difference? To me it looks like you've just used two different syntax for the same thing.

It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. This can happen after the program has been running perfectly for some time. Just use cstrings - char arrays terminated with '\0' (NULL).

Your symptom is typical of the sort of problem that the String class can cause.

...R

Delta_G:
What is the difference?

If the optimizer is aggressive and the code is similar to what is in the original post then nothing. The generated code is identical.

Otherwise, this is generated for the array (Serial.println(ssid) for an AVR processor)...

 560:	88 e1       	ldi	r24, 0x18	; 24
 562:	91 e0       	ldi	r25, 0x01	; 1
 564:	0e 94 69 01 	call	0x2d2	; 0x2d2 <_ZN5Print7printlnEPKc.constprop.3>

"ldi" is load immediate. The constant 0x0118 is loaded into the r24:r25 register pair. 0x0118 is presumably the location of the first byte of the actual string.

This is generated for the pointer (Serial.println(ssid) for an AVR processor)...

 568:	80 91 00 01 	lds	r24, 0x0100	; 0x800100 <__data_start>
 56c:	90 91 01 01 	lds	r25, 0x0101	; 0x800101 <__data_start+0x1>
 570:	0e 94 69 01 	call	0x2d2	; 0x2d2 <_ZN5Print7printlnEPKc.constprop.3>

"lds" is load from SRAM. Whatever two byte value stored at SRAM address 0x0100 is loaded into the r24:r25 register pair. An extra two bytes are needlessly consumed by the pointer.

Make sense?