cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Timeout Error when sending message to multiple numbers

jhomcosta
New Contributor

Hello! I usualy got to send a sms up to 400 - 500 customers once a month, I'm doing a php curl code like this:

 

 while ( $row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) {

      $fullName = $row['NOME'];
      $firstName = explode(" ", $fullName)[0];
      $msg = "[CHPR] " . $firstName . ", lembramos que o seu boleto com vencimento em " . $row['DTVENC'] . " já está disponível em seu e-mail e no portal. Se preferir, use o código de barras a seguir para realizar o pagamento, caso ainda não o tenha feito:\n" . $row['IPTE'] . "\n- Att, Colégio Suíço-Brasileiro.";
      $serie = $serie == 254 ? 0 : $serie + 1;
      $row['TEL1'] = formatPhoneNumber($row['TEL1']);


      $payload = [
        "NumUsu" => "user_name",
        "Senha" => "password",
        "SeuNum1" => 'V'.$row['DTVENC'],
        "SeuNum2" => "WebApp",
        "Serie" => (string)$serie,
        "Celular" => $row['TEL1'],
        "Mensagem" => $msg,
      ];
     
     
      $options = [
          "method" => "POST",
          "payload" => http_build_query($payload),
      ];

      $options["header"] = "Content-length: ".strlen($options["payload"]);
   
      $context = stream_context_create(["http" => $options]);

     
      //POST PARA O SERVICO DE SMS!!
      $curl = curl_init();
      curl_setopt_array($curl, [
        CURLOPT_URL => "url",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => http_build_query($payload),
        CURLOPT_TIMEOUT => 600,
      ]);

      $response = curl_exec($curl);
     
      if ($response === false) {
        $error = error_get_last();
        echo "An error occurred: " . $error['message'];
      }      
     
      curl_close($curl);

It sends the message to about 350 - 380 numbers and then it does timeout. Any ideias on how could i solve this ? Thanks!


2 REPLIES 2

Shahzad_Ismail
Community Manager
Community Manager

Hi Jhonata,

For this type of issue we recommend you contact Sinch Support

Thanks and kind regards,

Shahzad Ismail
Head of Knowledge Management and Community Engagement, Sinch

Ok, thanks!