Help UltraSonic Counter Through the Internet

Hi, Thank you for taking time and reading my post

I have already made the code although its poor since I am new to arduino

I have and Ethernet Shield and Uno Rev3

my problem is when I use the Yaler server the code does not loop and stuck in this line:
EthernetClient client = server.available(); (until I refresh the page it loops and stuck again)
However, when I use the local network the code works perfect without any problem

Thanx in addvance

the code is as follows

#include <SPI.h>
#include <Ethernet.h>
#include <YalerEthernetServer.h>


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,101);

// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):

EthernetServer server(80);
//YalerEthernetServer server("try.yaler.net", 80, "gsiot-r7q0-9bm5");     


void setup() {
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  //Ethernet.begin(mac);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}

long x=0,y=0,z=0;
void loop() {
  // establish variables for duration of the ping,
  // and the distance result in inches and centimeters:
  long duration1, cm1, duration2, cm2;

  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  pinMode(3, OUTPUT);// attach pin 3 to Trig of HC-SR04 #1
  digitalWrite(3, LOW);
  delayMicroseconds(2);
  digitalWrite(3, HIGH);
  delayMicroseconds(5);
  digitalWrite(3, LOW);
  
  // The same pin is used to read the signal from the PING))): a HIGH
  // pulse whose duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode (4, INPUT);//attach pin 4 to Echo of HC-SR04 #1
  duration1 = pulseIn(4, HIGH);

  pinMode(5, OUTPUT);// attach pin 5 to Trig of HC-SR04 #2
  digitalWrite(5, LOW);
  delayMicroseconds(2);
  digitalWrite(5, HIGH);
  delayMicroseconds(5);
  digitalWrite(5, LOW);

 pinMode (6, INPUT);//attach pin 6 to Echo of HC-SR04 #2
  duration2 = pulseIn(6, HIGH);
  // convert the time into a distance
  cm1 = microsecondsToCentimeters(duration1);
  cm2 = microsecondsToCentimeters(duration2);

   Serial.print(cm1);
   Serial.print("cm, ");
   Serial.print(cm2);
   Serial.print("cm");
   Serial.println();
  if((cm1 < 70) || (cm2<70))
{
if(cm1 < cm2)
{  
++x;
++y;
}
else if(cm2 < cm1) 
{
--x;
++z;
}
Serial.print( "The number of people inside is " );
Serial.print(x);
Serial.println();
Serial.print( "The number of people got in is ");
Serial.print(y);
Serial.println();
Serial.print( "The number of people got out is ");
Serial.print(z);
Serial.println();

while ((cm1 < 70) || (cm2<70))
{
  digitalWrite(3, LOW);
  delayMicroseconds(2);
  digitalWrite(3, HIGH);
  delayMicroseconds(5);
  digitalWrite(3, LOW);
  duration1 = pulseIn(4, HIGH);
  
  digitalWrite(5, LOW);
  delayMicroseconds(2);
  digitalWrite(5, HIGH);
  delayMicroseconds(5);
  digitalWrite(5, LOW);
  duration2 = pulseIn(6, HIGH);
  
  // convert the time into a distance
  cm1 = microsecondsToCentimeters(duration1);
  cm2 = microsecondsToCentimeters(duration2);
}
delay(2000);
}
////////////////////////////
listenForEthernetClients();
////////////////////////////
delay(10);
}
long microsecondsToCentimeters(long microseconds)
{
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;
}

 void listenForEthernetClients() {
          EthernetClient client = server.available();
          if (client) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
 /////////////////////////////
    client.print( "The number of people inside is " );
    client.print(x);
    client.println("
");       
    client.print( "The number of people got in is ");
    client.print(y);
    client.println("
");       
    client.print( "The number of people got out is ");
    client.print(z);
    client.println("
");
    client.println("</html>");
 
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
}
 }

,

my problem is when I use the Yaler server the code does not loop and stuck in this line:
EthernetClient client = server.available(); (until I refresh the page it loops and stuck again)

How do you know this? The code does something when a client connects. It does something else if there is no client connected. It is impossible for "it" to get "stuck" there.

          // output the value of each analog input pin

Not at all what that code does. Stupid comments MUST be correct.

Where did you get the YalerEthernetServer library, and why are you using it, when the regular server code works so well?

Thanks for your reply
I want the yaler server to connect to the arduino remotely since the regular server connects me only if i am in the same network
I have downloaded the library from thier website

So you are telling me that if client connects it does a job and if client is not connected it does another job
How can make the arduino program runs without any interruption in my case the counter sensors while client is not available and if client connects it just adds the printing commands to the code
help please because I am new to arduino coding

anyone can help please ?