title: Maximum execution time of 60 seconds exceeded
body: <p>I have got a couple of images I want to send to a WhatsApp number using Twilio. I want to then send a text message only after all the images have been delivered. While sending an image, I specify a callback that gets the delivery status and stores it using redis. After I have made a call to send these images, I check the delivery statuses of all the images, if none of the images have its status to be equal to zero, I then send the text message else I do a check until I get a delivery status that is not zero. However, my proposed solution is timing out. I am getting this error - <code>Maximum execution time of 60 seconds exceeded from Redis</code> Even the images are not sending. See the attached image<a href="https://i.stack.imgur.com/i6ARf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i6ARf.png" alt="enter image description here"></a></p>
  
  <p>This is what I am doing:</p>
  
  <pre><code>Route::get('test', function (){
      $redis = new \Predis\Client();
      $images = \App\ProductImage::where('product_id', 7)-&gt;get();
  
      foreach ($images as$image){
          $imgUrl = url(env('BOT_URL').'/images/'.$image['img_url']);
          $sid[] = \App\Libraries\Utilities::sendMediaMessage('+23xxxxx', '', $imgUrl);
      }
      foreach ($sid as $id){
          $statuses[] = $redis-&gt;get($id);
      }
  
      if(in_array(0, $statuses)){
             $check = \App\Libraries\Utilities::checkIfWhatsAppStatusHasChanged($sid);
          if ($check){
              \App\Libraries\Utilities::sendWhatsAppMessage('+23xxxxx', 'Send message - had to check');
          }
      }else{
          \App\Libraries\Utilities::sendWhatsAppMessage('+23xxxx', 'Send message ');
      }
  
  });
  </code></pre>
  
  <p>Here is the sendMediaMessage method</p>
  
  <pre><code> public static function sendMediaMessage($phone, $msg, $mediaUrl){
               try{
  
              $client = new Client(env('TWILIO_SID'), env('TWILIO_TOKEN'));
              $send = $client-&gt;messages-&gt;create(
                  "whatsapp:".$phone, // Text this number
                  array(
                      'from' =&gt; "whatsapp:".env('TWILIO_NUMBER'), // From a valid Twilio number
                      'body' =&gt; $msg,
                      'mediaUrl' =&gt; $mediaUrl,
                      'statusCallback' =&gt; url(env('BOT_URL').'/whatsapp-delivery-status')
                  )
              );
              //
              if($send != false){
                  $message_sid = $send-&gt;sid;
                  return $message_sid;
              }
  
          }catch (\Exception $exception){
          }
      }
  </code></pre>
  
  <p>Here is the callback method - </p>
  
  <pre><code>   public function checkWhatsapDelivery(Request $request)
      {
          $redis = new Client();
          $body = $request-&gt;all();
          $messageSid = $body['MessageSid'];
          $MessageStatus = $body['MessageStatus'];
          $status_id = Utilities::getWhatsappMessageStatus($MessageStatus);
          $redis-&gt;set($messageSid, $status_id);
      }
  </code></pre>
  
  <p>Here is the getWhatsappMessageStatus method</p>
  
  <pre><code> public static function getWhatsappMessageStatus($status){
          switch (strtolower($status)){
              case 'queued':
                  $id = 1;
                  break;
              case 'failed':
                  $id = 2;
                  break;
              case 'sent':
                  $id = 3;
                  break;
              case 'delivered':
                  $id = 4;
                  break;
              case 'read':
                  $id = 5;
                  break;
              default:
                  $id = 0;
          }
          return $id;
      }
  </code></pre>
  
  <p>Here is checkIfWhatsAppStatusHasChanged method</p>
  
  <pre><code>  public static function checkIfWhatsAppStatusHasChanged($sids){
          $statuses = self::getWhatsAppStatuses($sids);
          if(in_array(0, $statuses)){
              self::checkIfWhatsAppStatusHasChanged($sids);
          }else{
              return true;
          }
      }
  </code></pre>
  
  <p>Here is getWhatsAppStatuses method</p>
  
  <pre><code>public static function getWhatsAppStatuses($sids){
          $redis = new \Predis\Client();
          foreach ($sids as $id){
              $statuses[] = $redis-&gt;get($id);
          }
          return $statuses;
  }
  </code></pre>
  
  <p>Please what am I doing wrong?</p>