glushkovds / php-smpp

WIP. Implementation SMPP v3.4 protocol. Includes sending and listening USSD.
MIT License
19 stars 11 forks source link

Laravel : Attempt to read property "body" on bool #15

Open RouxCool opened 11 months ago

RouxCool commented 11 months ago

Version Laravel : 8.83.27 Version PHP : 8.2.8


1° Est-ce qu'il y a une erreur dans mes informations d'environnement ?

SMPP_HOST = gra.smpp.ovh:2776 SMPP_LOGIN = {SystemID} sur l'interface d'OVH. SMPP_PASSWORD = mot de passe fournis sur l'interface OVH


2° Pourquoi j'ai toujours cette erreur lors de l'envoie d'SMS ?

Code :

public function test_global() {
    $service = new \PhpSmpp\Service\Sender([env('SMPP_HOST')], env('SMPP_LOGIN'), env('SMPP_PASSWORD'), 'BIND_MODE_TRANSMITTER');
    $smsId = $service->send(33712345678, 'Test', env('SMPP_SENDER'));
}

Erreur :

Got error while sending SMS. Retry=0
Got error while sending SMS. Retry=1

• Tests\Feature\MasterTest > global
 PHPUnit\Framework\ExceptionWrapper 

Attempt to read property "body" on bool

at vendor/glushkovds/php-smpp/src/Client.php:520
  516▕ 
  517▕         $response = $this->sendCommand(SMPP::SUBMIT_SM, $pdu, $needReply);
  518▕         Log::error($response);
  519▕         if ($needReply) {
➜ 520▕             $body = unpack("a*msgid", $response->body);
  521▕             return $body['msgid'];
  522▕         }
  523▕         return null;
  524▕     }
vstriletskyi commented 2 months ago

Got the same error. Do you have solution?

momostafa commented 2 months ago

Got the same error. Do you have solution?

Make sure you are using the latest version and $nullTerminateOctetstrings = false; ->setSendTimeout(30000)

vstriletskyi commented 2 months ago

Got the same error. Do you have solution?

Make sure you are using the latest version and $nullTerminateOctetstrings = false; ->setSendTimeout(30000)

How i can setSendTimeout?

I had this code: `$conf = config('laravel-smpp'); $this->conf = $conf;

    $this->smpp = new Sender(
        [$conf['providers']['example']['host'] . ':' . $conf['providers']['example']['port']], 
        $conf['providers']['example']['login'], 
        $conf['providers']['example']['password'],
        Client::BIND_MODE_TRANSCEIVER,
        true
    );

    $this->smpp->client::$sms_registered_delivery_flag = 0x01;
    $this->smpp->client::$addr_ton = $conf['defaults']['source_ton'];
    $this->smpp->client::$addr_npi = $conf['defaults']['source_npi'];
    $this->smpp->client->nullTerminateOctetstrings = false;
    $this->smpp->client->getTransport()->setSendTimeout(30000); // this is right?`
momostafa commented 2 months ago

first make sure that all $conf has actual smpp account not just dummy example then run this in the terminal to update your package composer update glushkovds/php-smpp --lock

momostafa commented 2 months ago

and change Client::BIND_MODE_TRANSCEIVER to Client::BIND_MODE_TRANSMITTER