Controlling a Relay - intermittent responsiveness

Hi, I’m wondering if someone can help me with this. I have what is a functional sketch to control a relay on and off on an Arduino Uno. However the virtual button is unresponsive for periods of up to 30 seconds at a time and usually around 20 seconds, with periods of responsiveness lasting 3 to 10 seconds. I’ve tried a timer sketch with a push button which seems to have the same issues. I’ve tried to relocate lines of code from the loop function to the Blynk_Write function which doesn’t resolve the issue. As an alternative, if the responsiveness issue can’t be solved, can I Blynk_Read the button to check the state? A delayed reaction is fine. The problem with the current situation is that when the virtual button is pressed, it sends a “1/HIGH” but it’s momentary, and the virtual button stays ON but the relay will never come on with this sketch unless you keep pressing it.

//#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>

int digitalPin=A4;
int value;
int countBlynkWrite;
unsigned long previousMillis = 0;
const long interval = 500;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "c6a38e9ac88d46f9ba916e9f8a28056a";

void onOrOff()  {
  //  Serial.println("Blynk run succeess");
    if (value >0)
    digitalWrite(digitalPin, HIGH);
    Serial.println("relay on");
} else{
    digitalWrite(digitalPin, LOW);
    Serial.println("relay off");

void setup()
  pinMode(digitalPin, OUTPUT);
  digitalWrite(digitalPin, LOW);

//    Serial.print("Blynk_Write Count:  ");
//    countBlynkWrite=countBlynkWrite+1;
//    Serial.println(countBlynkWrite);

void loop() {
    unsigned long currentMillis=millis();
    if (currentMillis-previousMillis >= interval) {

Hello. should be run in a loop always. You need to move it out from if condition.