Wemos D1 mini freezing after a few minutes
I doubt this is the problem, but this code looks wrong.

  int redval = red_val.toInt();
  analogWrite(D5, redval);
  redval = redval &gt;= 1023 ? 1023 : redval &lt;= 0 ? 0 : redval;
  if (redval == 0)
    analogWrite(D5, 0);


I think it should be more like this:

  int redval = red_val.toInt();
  if (redval &gt; 1023)  // If its =1023 you do need to set it to 1023.
    redval= 1023;
  else if (redval &lt; 0)
    redval = 0;
  analogWrite(D5, redval);


The inline if statement is too ugly and doesn't really add anything.

To be honest I would look at pulling this code into functions to make it easier to read and I suspect you will find the problem.

When these microprocessors stop after a while its usually memory, heat or electrical.  If you have checked the electrics and its stopping quite quickly its probably a memory leak.  So refactoring your code might help people spot the problem easier.

You might want to replace you call to setColour()  with a call to Serial.println() and see if that cure the problem.  If it doesn't then your problem is with the way you are calling client.