glushkovds / php-smpp

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

Testing with FakeTransport: Failed to read reply to command: 0x9 #12

Closed ghost closed 1 year ago

ghost commented 1 year ago

Hi! I'm testing how to send SMS, using FakeTransport:

<?php 
include_once __DIR__ . '/vendor/autoload.php';
use \PhpSmpp\Service\Sender;

$service = new \PhpSmpp\Service\Sender([], '', '', true);
$service->client->setTransport(new \PhpSmpp\Transport\FakeTransport());
$smsId = $service->send(34666555444, 'First test', 'AVODEV');
var_dump($smsId);

I have an exception related with the reply of command:

PHP Fatal error:  Uncaught PhpSmpp\Exception\SmppException: Failed to read reply to command: 0x9 in /home/avodev/workspace/avosms/vendor/glushkovds/php-smpp/src/Client.php:715

This is the stack trace:

Stack trace:
#0 /home/avodev/workspace/avosms/vendor/glushkovds/php-smpp/src/Client.php(625): PhpSmpp\Client->sendCommand()
#1 /home/avodev/workspace/avosms/vendor/glushkovds/php-smpp/src/Client.php(193): PhpSmpp\Client->bind()
#2 /home/avodev/workspace/avosms/vendor/glushkovds/php-smpp/src/Service/Sender.php(25): PhpSmpp\Client->bindTransceiver()
#3 /home/avodev/workspace/avosms/vendor/glushkovds/php-smpp/src/Service/Service.php(80): PhpSmpp\Service\Sender->bind()
#4 /home/avodev/workspace/avosms/vendor/glushkovds/php-smpp/src/Service/Sender.php(33): PhpSmpp\Service\Service->enshureConnection()
#5 /home/avodev/workspace/avosms/sender.php(8): PhpSmpp\Service\Sender->send()
#6 {main}
  thrown in /home/avodev/workspace/avosms/vendor/glushkovds/php-smpp/src/Client.php on line 715

Thank you!

ghost commented 1 year ago

I understood the problem. In your examples, you only use hosts, login and pass params for Service instance. This is not correct, because seen the code, bindMode is mandatory too.

I added "true" for debug mode (last and optional parameter), but this was added automatically to bindMode parameter.

Now is working well, only in receiver and transmitter mode (not working in transceiver mode)